Module

React.Halo

Package
purescript-react-halo
Repository
robertdp/purescript-react-halo

Re-exports from Control.Monad.Error.Class

#throwError Source

throwError :: forall e m a. MonadThrow e m => e -> m a

Re-exports from Control.Monad.Reader.Class

#ask Source

ask :: forall r m. MonadAsk r m => m r

#asks Source

asks :: forall a m r. MonadAsk r m => (r -> a) -> m a

Projects a value from the global context in a MonadAsk.

Re-exports from Control.Monad.State.Class

#state Source

state :: forall s m a. MonadState s m => (s -> (Tuple a s)) -> m a

#put Source

put :: forall s m. MonadState s m => s -> m Unit

Set the state.

#modify_ Source

modify_ :: forall m s. MonadState s m => (s -> s) -> m Unit

#modify Source

modify :: forall m s. MonadState s m => (s -> s) -> m s

Modify the state by applying a function to the current state. The returned value is the new state value.

#gets Source

gets :: forall a m s. MonadState s m => (s -> a) -> m a

Get a value which depends on the current state.

#get Source

get :: forall s m. MonadState s m => m s

Get the current state.

Re-exports from Control.Monad.Trans.Class

#lift Source

lift :: forall t a m. MonadTrans t => Monad m => m a -> t m a

Re-exports from Control.Monad.Writer.Class

#tell Source

tell :: forall w m. MonadTell w m => w -> m Unit

Re-exports from Control.Parallel.Class

#parallel Source

parallel :: forall f m. Parallel f m => m ~> f

#sequential Source

sequential :: forall f m. Parallel f m => f ~> m

Re-exports from Data.Tuple.Nested

#(/\) Source

Operator alias for Data.Tuple.Tuple (right-associative / precedence 6)

Shorthand for constructing n-tuples as nested pairs. a /\ b /\ c /\ d /\ unit becomes Tuple a (Tuple b (Tuple c (Tuple d unit)))

#type (/\) Source

Operator alias for Data.Tuple.Tuple (right-associative / precedence 6)

Shorthand for constructing n-tuple types as nested pairs. forall a b c d. a /\ b /\ c /\ d /\ Unit becomes forall a b c d. Tuple a (Tuple b (Tuple c (Tuple d Unit)))

Re-exports from Effect.Aff.Class

#liftAff Source

liftAff :: forall m. MonadAff m => Aff ~> m

Re-exports from Effect.Class

#liftEffect Source

liftEffect :: forall m a. MonadEffect m => Effect a -> m a

Re-exports from React.Basic.Hooks

#JSX Source

data JSX :: Type

Represents rendered React VDOM (the result of calling React.createElement in JavaScript).

JSX is a Monoid:

  • append
    • Merge two JSX nodes using React.Fragment.
  • mempty
    • The empty node; renders nothing.

Hint: Many useful utility functions already exist for Monoids. For example, guard can be used to conditionally render a subtree of components.

Instances

Re-exports from React.Halo.Component

#UseHalo Source

newtype UseHalo props state action hooks

Instances

#HookSpec Source

type HookSpec props state action m = { eval :: Lifecycle props action -> HaloM props state action m Unit, initialState :: state, props :: props }

#ComponentSpec Source

type ComponentSpec props state action m = { eval :: Lifecycle props action -> HaloM props state action m Unit, initialState :: state, render :: { props :: props, send :: action -> Effect Unit, state :: state } -> JSX }

#useHalo Source

useHalo :: forall props action state. HookSpec props state action Aff -> Hook (UseHalo props state action) (state /\ (action -> Effect Unit))

Run renderless Halo in the current component. This allows Halo to be used with other hooks and other ways of building components.

#component_ Source

component_ :: forall action state. String -> ComponentSpec Unit state action Aff -> Effect JSX

Build a propless component by providing a name and Halo component spec.

#component Source

component :: forall props action state. String -> ComponentSpec props state action Aff -> Effect (props -> JSX)

Build a component by providing a name and Halo component spec.

Re-exports from React.Halo.Internal.Control

#HaloM Source

newtype HaloM props state action m a

The Halo evaluation monad. It lifts the HaloF algebra into a free monad.

  • props are the component props
  • state is the component state
  • action is the set of actions that the component handles
  • m is the monad used during evaluation
  • a is the result type

Instances

#HaloAp Source

newtype HaloAp props state action m a

The Halo parallel evaluation applicative. It lifts HaloM into a free applicative.

  • props are the component props
  • state is the component state
  • action is the set of actions that the component handles
  • m is the monad used during evaluation
  • a is the result type

Instances

#unsubscribe Source

unsubscribe :: forall props state action m. SubscriptionId -> HaloM props state action m Unit

Cancels the event subscription belonging to the SubscriptionId.

#subscribe' Source

subscribe' :: forall props state action m. (SubscriptionId -> Event action) -> HaloM props state action m SubscriptionId

Same as subscribe but the event-producing logic is also passed the SuscriptionId. This is useful when events need to unsubscribe themselves.

#subscribe Source

subscribe :: forall m action state props. Event action -> HaloM props state action m SubscriptionId

Subscribe to new actions from an Event. Subscriptions will be automatically cancelled when the component unmounts.

Returns a SubscriptionId which can be used with unsubscribe to manually cancel a subscription.

#props Source

props :: forall state action m props. HaloM props state action m props

Read the current props.

#kill Source

kill :: forall props state action m. ForkId -> HaloM props state action m Unit

Kills the process belonging to the ForkId.

#hoist Source

hoist :: forall m' m action state props. Functor m => (m ~> m') -> (HaloM props state action m) ~> (HaloM props state action m')

Hoist (transform) the base monad of a HaloM expression.

#fork Source

fork :: forall props state action m. HaloM props state action m Unit -> HaloM props state action m ForkId

Start a HaloM process running independantly from the current "thread". Forks are tracked automatically and killed when the Finalize event occurs (when the component unmounts). New forks can still be created during the Finalize event, but once evaluation ends there will be no way of killing them.

Returns a ForkId for the new process.

Re-exports from React.Halo.Internal.Eval

#EvalSpec Source

type EvalSpec props state action m = { onAction :: action -> HaloM props state action m Unit, onFinalize :: Maybe action, onInitialize :: props -> Maybe action, onUpdate :: props -> props -> Maybe action }

A simpler interface for building the components eval function. The main lifecycle events map directly into actions, so only the action handling logic needs to be written using HaloM.

#makeEval Source

makeEval :: forall props state action m. (EvalSpec props state action m -> EvalSpec props state action m) -> Lifecycle props action -> HaloM props state action m Unit

Given an EvalSpec builder, it will return an eval function.

#defaultEval Source

defaultEval :: forall m state action props. EvalSpec props state action m

The empty EvalSpec.

Re-exports from React.Halo.Internal.Types

#Lifecycle Source

data Lifecycle props action

The Halo lifecycle events.

  • Initialize contains the initial props. It occurs when the component mounts, and only once per component.
  • Update contains the previous and new props. It occurs when the component re-renders and the props have changes.
  • Action contains the dispatched action. It occurs each time an action is dispatched to be eval'd, up until the Finalize event
  • Finalize occurs when the component unmounts.

Constructors

#ForkId Source

newtype ForkId

Instances