Module

React.Halo

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

Re-exports from React.Halo.Component

#UseHalo Source

newtype UseHalo props ctx state action hooks

Instances

#HookSpec Source

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

#ComponentSpec Source

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

#useHalo Source

useHalo :: forall props ctx state action. HookSpec props ctx state action Aff -> Hook (UseHalo props ctx 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 hooks props ctx state action. String -> ComponentSpec hooks props ctx state action Aff -> Component props

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

Re-exports from React.Halo.Internal.Control

#HaloM Source

newtype HaloM props ctx state action (m :: Type -> Type) a

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

  • props are the component props
  • ctx is some component context
  • 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 ctx state action (m :: Type -> Type) a

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

  • props are the component props
  • ctx is some component context
  • 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 ctx state action m. SubscriptionId -> HaloM props ctx state action m Unit

Cancels the event subscription belonging to the SubscriptionId.

#subscribe' Source

subscribe' :: forall props ctx state action m. (SubscriptionId -> Emitter action) -> HaloM props ctx 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 props ctx state action m. Emitter action -> HaloM props ctx state action m SubscriptionId

Subscribe to new actions from an Emitter. 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 props ctx state action m. HaloM props ctx state action m props

Read the current props.

#kill Source

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

Kills the process belonging to the ForkId.

#hoistAp Source

hoistAp :: forall props ctx state action m m'. Functor m => (m ~> m') -> (HaloAp props ctx state action m) ~> (HaloAp props ctx state action m')

Hoist (transform) the base applicative of a HaloAp expression.

#hoist Source

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

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

#fork Source

fork :: forall props ctx state action m. HaloM props ctx state action m Unit -> HaloM props ctx 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.

#context Source

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

Read the current context.

Re-exports from React.Halo.Internal.Eval

#EvalSpec Source

type EvalSpec props ctx state action m = { onAction :: action -> HaloM props ctx state action m Unit, onFinalize :: Maybe action, onInitialize :: { context :: ctx, props :: props } -> Maybe action, onUpdate :: { context :: ctx, props :: props } -> { context :: ctx, 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.

#mkEval Source

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

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

#defaultEval Source

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

The empty EvalSpec.

Re-exports from React.Halo.Internal.Types

#Lifecycle Source

data Lifecycle props ctx 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