Halogen.Query.HalogenM
- Package
- purescript-halogen
- Repository
- purescript-halogen/purescript-halogen
#HalogenF Source
data HalogenF state action slots output m a
The Halogen component eval algebra.
state
is the component's stateaction
is the type of actions; events internal to the component that can be evaluatedslots
is the set of slots for addressing child componentsoutput
is the type of output messages the component can raisem
is the monad used during evaluationa
is the result of the HalogenF expression (see HalogenM for an example).
Constructors
State (state -> Tuple a state)
Subscribe (SubscriptionId -> Emitter action) (SubscriptionId -> a)
Unsubscribe SubscriptionId a
Lift (m a)
ChildQuery (ChildQueryBox slots a)
Raise output a
Par (HalogenAp state action slots output m a)
Fork (HalogenM state action slots output m Unit) (ForkId -> a)
Kill ForkId a
GetRef RefLabel (Maybe Element -> a)
Instances
#HalogenM Source
newtype HalogenM state action slots output m a
The Halogen component eval effect monad.
state
is the component's stateaction
is the type of actions; veents internal to the component that can be evaluatedslots
is the set of slots for addressing child componentsoutput
is the type of output messages the component can raisem
is the monad used during evaluationa
is the result of the HalogenM expression. Use the following pattern:handleAction :: Action -> H.HalogenM State Action Slots Output m Unit
handleQuery :: forall a. Query a -> H.HalogenM State Action Slots Output m (Maybe a)
Constructors
Instances
Functor (HalogenM state action slots output m)
Apply (HalogenM state action slots output m)
Applicative (HalogenM state action slots output m)
Bind (HalogenM state action slots output m)
Monad (HalogenM state action slots output m)
(Semigroup a) => Semigroup (HalogenM state action slots output m a)
(Monoid a) => Monoid (HalogenM state action slots output m a)
(MonadEffect m) => MonadEffect (HalogenM state action slots output m)
(MonadAff m) => MonadAff (HalogenM state action slots output m)
Parallel (HalogenAp state action slots output m) (HalogenM state action slots output m)
MonadTrans (HalogenM state action slots o)
MonadRec (HalogenM state action slots output m)
MonadState state (HalogenM state action slots output m)
(MonadAsk r m) => MonadAsk r (HalogenM state action slots output m)
(MonadTell w m) => MonadTell w (HalogenM state action slots output m)
(MonadThrow e m) => MonadThrow e (HalogenM state action slots output m)
#HalogenAp Source
newtype HalogenAp state action slots output m a
An applicative-only version of HalogenM
to allow for parallel evaluation.
Constructors
Instances
#SubscriptionId Source
newtype SubscriptionId
The ID value associated with a subscription. Allows the subscription to be stopped at a later time.
Constructors
Instances
#subscribe Source
subscribe :: forall state action slots output m. Emitter action -> HalogenM state action slots output m SubscriptionId
Subscribes a component to an Emitter
.
When a component is disposed of any active subscriptions will automatically be stopped and no further subscriptions will be possible during finalization.
#subscribe' Source
subscribe' :: forall state action slots output m. (SubscriptionId -> Emitter action) -> HalogenM state action slots output m Unit
An alternative to subscribe
, intended for subscriptions that unsubscribe
themselves. Instead of returning the SubscriptionId
from subscribe'
, it
is passed into an Emitter
constructor. This allows emitted queries
to include the SubscriptionId
, rather than storing it in the state of the
component.
When a component is disposed of any active subscriptions will automatically be stopped and no further subscriptions will be possible during finalization.
#unsubscribe Source
unsubscribe :: forall state action slots output m. SubscriptionId -> HalogenM state action slots output m Unit
Unsubscribes a component from a subscription. If the subscription associated with the ID has already ended this will have no effect.
#fork Source
fork :: forall state action slots output m. HalogenM state action slots output m Unit -> HalogenM state action slots output m ForkId
Starts a HalogenM
process running independent from the current eval
"thread".
A commonly use case for fork
is in component initializers where some
async action is started. Normally all interaction with the component will
be blocked until the initializer completes, but if the async action is
fork
ed instead, the initializer can complete synchronously while the
async action continues.
Some care needs to be taken when using a fork
that can modify the
component state, as it's easy for the forked process to "clobber" the state
(overwrite some or all of it with an old value) by mistake.
When a component is disposed of any active forks will automatically be killed. New forks can be started during finalization but there will be no means of killing them.
- Modules
- Halogen
- Halogen.
Aff - Halogen.
Aff. Driver - Halogen.
Aff. Driver. Eval - Halogen.
Aff. Driver. State - Halogen.
Aff. Util - Halogen.
Component - Halogen.
Component. Profunctor - Halogen.
Data. OrdBox - Halogen.
Data. Slot - Halogen.
HTML - Halogen.
HTML. Core - Halogen.
HTML. Elements - Halogen.
HTML. Elements. Keyed - Halogen.
HTML. Events - Halogen.
HTML. Properties - Halogen.
HTML. Properties. ARIA - Halogen.
Query - Halogen.
Query. ChildQuery - Halogen.
Query. Event - Halogen.
Query. HalogenM - Halogen.
Query. HalogenQ - Halogen.
Query. Input - Halogen.
VDom. Driver