Module

Dispatcher.React

Package
purescript-dispatcher-react
Repository
doolse/purescript-dispatcher-react

#ReactReaderT Source

type ReactReaderT props state m a = ReaderT (ReactThis props state) m a

The type of all React action handling functions

#ReactLifecycle Source

type ReactLifecycle props state eval eff = RWS eval Unit (ReactSpec props state eff) Unit

The type of React lifecycle methods - Reader Writer State (RWS) with the eval being the Reader type and the ReactSpec being the State type.

#getProps Source

getProps :: forall eff state props m. MonadEff (props :: ReactProps | eff) m => ReactReaderT props state m props

Get the React properties

#getState Source

getState :: forall eff access state props m. MonadEff (state :: ReactState (read :: Read | access) | eff) m => ReactReaderT props state m state

Get the React state

#modifyState Source

modifyState :: forall eff state props m. MonadEff (state :: ReactState ReadWrite | eff) m => (state -> state) -> ReactReaderT props state m Unit

Modify the React state

#getRefs Source

getRefs :: forall m state props eff. MonadEff (refs :: ReactRefs ReadOnly | eff) m => ReactReaderT props state m Refs

Get the React refs

#unsafeWithRef Source

unsafeWithRef :: forall m eff ref state props. MonadEff (refs :: ReactRefs ReadOnly | eff) m => (ref -> Eff (refs :: ReactRefs ReadOnly | eff) Unit) -> String -> ReactReaderT props state m Unit

Run an effect with on the object pointed to by the ref string. (or do nothing if it doesn't exist)

#unsafeWithRef' Source

unsafeWithRef' :: forall a m eff ref state props. MonadEff (refs :: ReactRefs ReadOnly | eff) m => (ref -> Eff (refs :: ReactRefs ReadOnly | eff) a) -> String -> ReactReaderT props state m (Maybe a)

#emptyHandler Source

emptyHandler :: forall m a. Applicative m => a -> m Unit

an empty event handler

#execHandler Source

execHandler :: forall state props a m eff2 eff. MonadEff eff m => Eff eff2 a -> ReactReaderT props state m a

Run an Eff event handler

#ReactSpecCreator Source

class ReactSpecCreator eval initialstate render props state eff | eval initialstate render -> props state eff where

Members

  • createSpec :: eval -> initialstate -> (state -> render) -> ReactSpec props state eff

    Given an action evaluator, an initial state, and a render function, return a ReactSpec.

Instances

#ReactInitialState Source

class ReactInitialState eval initialstate props state eff | initialstate -> state where

Members

Instances

#ReactRender Source

class ReactRender eval renderer props state eff | renderer -> eff where

Members

Instances

#createComponent Source

createComponent :: forall eff renderer eval state2 state props. TypeEquals state2 state => ReactSpecCreator eval (ReactState state) renderer props state eff => state2 -> (state -> renderer) -> eval -> ReactClass props

Create a ReactClass with the given state, renderer and action evaluator

#createComponent' Source

createComponent' :: forall eff renderer initialstate eval state props. ReactSpecCreator eval initialstate renderer props state eff => initialstate -> (state -> renderer) -> eval -> ReactClass props

Create a ReactClass with the given initialstate function, renderer and action evaluator The initialstate function must return it's state value wrapped in the ReactState newtype

#createLifecycleComponent Source

createLifecycleComponent :: forall eff renderer eval state2 state props. TypeEquals state2 state => ReactSpecCreator eval (ReactState state) renderer props state eff => ReactLifecycle props state eval eff -> state2 -> (state -> renderer) -> eval -> ReactClass props

Create a ReactClass with the given lifecycle, state, renderer and action evaluator

#createLifecycleComponent' Source

createLifecycleComponent' :: forall eff renderer eval initialstate state props. ReactSpecCreator eval initialstate renderer props state eff => (RWS eval Unit (ReactSpec props state eff) Unit) -> initialstate -> (state -> renderer) -> eval -> ReactClass props

Create a ReactClass with the given lifecycle, initialstate function, renderer and action evaluator The initialstate function must return it's state value wrapped in the ReactState newtype

#didMount Source

didMount :: forall eff action state props eval. Dispatchable eval (ReactThis props state) action (Eff (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadWrite | eff) Unit) => action -> ReactLifecycle props state eval eff

A ReactLifecycle for dispatching the componentDidMount React lifecycle function

#willUnmount Source

willUnmount :: forall eff action state props eval. Dispatchable eval (ReactThis props state) action (Eff (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadOnly | eff) Unit) => action -> ReactLifecycle props state eval eff

A ReactLifecycle for dispatching the componentWillUnmount React lifecycle function

#ReactState Source

newtype ReactState s

A newtype to signify the React State Used to denote the state returned from an initial state function

Constructors

Instances

#ReactProps Source

newtype ReactProps p

A newtype representing the React Props Useful in renderers or initial state functions

Constructors

Instances

#ReactChildren Source

newtype ReactChildren

A newtype representing the React children array Useful in renderers

Constructors

Instances