Module

React.Redox

Package
purescript-react-redox
Repository
coot/purescript-react-redox

#DispatchFn Source

type DispatchFn state dsl reff eff = Free dsl (state -> state) -> Eff (redox :: RedoxStore reff | eff) (Canceler (redox :: RedoxStore reff | eff))

#unsafeShallowEqual Source

unsafeShallowEqual :: forall a. Fn2 a a Boolean

#unsafeStrictEqual Source

unsafeStrictEqual :: forall a. Fn2 a a Boolean

#withStore Source

withStore :: forall eff reff dsl props state. Store state -> (Store state -> DispatchFn state dsl reff eff) -> ReactClass props -> ReactClass props

You need to wrap your most top-level component with withStore. It makes the store and the bound dispatch function avaialble through React context. Then you can connect a component with connect (or connect') and get access to the store and the dispatch function.

#RedoxContext Source

type RedoxContext state dsl reff eff = { dispatch :: DispatchFn state dsl reff eff, store :: Store state }

#connect' Source

connect' :: forall eff reff props' props dsl state' state. Proxy state -> Getter' state state' -> (DispatchFn state dsl (read :: ReadRedox, subscribe :: SubscribeRedox | reff) eff -> state' -> props' -> props) -> ReactClass props -> ReactSpec props' (ConnectState state') (context :: CONTEXT, redox :: RedoxStore (read :: ReadRedox, subscribe :: SubscribeRedox | reff) | eff)

You must wrap the resulting component with ReactHocs.accessContext from purescript-react-hocs. Checkout connect bellow. This function makes the redox store and dispatch function available through the context. The first argument is a Lens that identifies the part of the store state that you want to subscribe for. The second argument let you combine state and additional properties props' to get props of the class that you are connecting to the store. You can read the context with:

ReactHocs.readContext this >>= pure <<< _.redox :: Eff eff (RedoxContext state (Free dsl (state -> state))  eff)

#connect Source

connect :: forall eff' reff props' props dsl state' state. Proxy state -> Getter' state state' -> (DispatchFn state dsl (read :: ReadRedox, subscribe :: SubscribeRedox | reff) eff' -> state' -> props' -> props) -> ReactClass props -> ReactClass props'

#dispatch Source

dispatch :: forall eff reff state rState rProps dsl. ReactThis rProps rState -> Free dsl (state -> state) -> Eff (context :: CONTEXT, redox :: RedoxStore reff | eff) (Canceler (context :: CONTEXT, redox :: RedoxStore reff | eff))
Modules
React.Redox