Module

Halogen.Query.EventSource

Package
purescript-halogen
Repository
slamdata/purescript-halogen

#EventSource Source

newtype EventSource f m

Constructors

#unEventSource Source

unEventSource :: forall m f. EventSource f m -> m { done :: m Unit, producer :: Producer (f SubscribeStatus) m Unit }

#interpret Source

interpret :: forall m g f. Functor m => (f ~> g) -> EventSource f m -> EventSource g m

#hoist Source

hoist :: forall n m f. Functor n => (m ~> n) -> EventSource f m -> EventSource f n

#SubscribeStatus Source

data SubscribeStatus

The status of an EventSource subscription. When a query raised by an EventSource evaluates to Done the producer will be unsubscribed from.

Constructors

Instances

#eventSource Source

eventSource :: forall eff a m f. MonadAff (avar :: AVAR | eff) m => ((a -> Eff (avar :: AVAR | eff) Unit) -> Eff (avar :: AVAR | eff) Unit) -> (a -> Maybe (f SubscribeStatus)) -> EventSource f m

Creates an EventSource for a callback that accepts one argument.

  • The first argument is the function that attaches the listener.
  • The second argument is a handler that optionally produces a value in f.

#eventSource' Source

eventSource' :: forall eff a m f. MonadAff (avar :: AVAR | eff) m => ((a -> Eff (avar :: AVAR | eff) Unit) -> Eff (avar :: AVAR | eff) (Eff (avar :: AVAR | eff) Unit)) -> (a -> Maybe (f SubscribeStatus)) -> EventSource f m

Similar to eventSource but allows the attachment function to return an action to perform when the handler is detached.

#eventSource_ Source

eventSource_ :: forall eff m f. MonadAff (avar :: AVAR | eff) m => (Eff (avar :: AVAR | eff) Unit -> Eff (avar :: AVAR | eff) Unit) -> f SubscribeStatus -> EventSource f m

Creates an EventSource for a callback that accepts no arguments.

  • The first argument is the function that attaches the listener.
  • The second argument is the query to raise whenever the listener is triggered.

#eventSource_' Source

eventSource_' :: forall eff m f. MonadAff (avar :: AVAR | eff) m => (Eff (avar :: AVAR | eff) Unit -> Eff (avar :: AVAR | eff) (Eff (avar :: AVAR | eff) Unit)) -> f SubscribeStatus -> EventSource f m

Similar to eventSource_ but allows the attachment function to return an action to perform when the handler is detached.

#catMaybes Source

catMaybes :: forall r a m. MonadRec m => Producer (Maybe a) m r -> Producer a m r

Takes a producer of Maybes and filters out the Nothings. Useful for constructing EventSources for producers that don't need to handle every event.

#produce Source

produce :: forall eff r a. ((Either a r -> Eff (avar :: AVAR | eff) Unit) -> Eff (avar :: AVAR | eff) Unit) -> Producer a (Aff (avar :: AVAR | eff)) r

#produce' Source

produce' :: forall eff r a. ((Either a r -> Eff (avar :: AVAR | eff) Unit) -> Eff (avar :: AVAR | eff) (Eff (avar :: AVAR | eff) Unit)) -> Aff (avar :: AVAR | eff) { cancel :: r -> Aff (avar :: AVAR | eff) Boolean, producer :: Producer a (Aff (avar :: AVAR | eff)) r }

#produceAff Source

produceAff :: forall m eff r a. MonadAff (avar :: AVAR | eff) m => ((Either a r -> Aff (avar :: AVAR | eff) Unit) -> Aff (avar :: AVAR | eff) Unit) -> Producer a m r

#produceAff' Source

produceAff' :: forall eff r a. ((Either a r -> Aff (avar :: AVAR | eff) Unit) -> Aff (avar :: AVAR | eff) (Aff (avar :: AVAR | eff) Unit)) -> Aff (avar :: AVAR | eff) { cancel :: r -> Aff (avar :: AVAR | eff) Boolean, producer :: Producer a (Aff (avar :: AVAR | eff)) r }