Module

Halogen.Query.EventSource

#EventSource

newtype EventSource f m

Constructors

#SubscribeStatus

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

#unEventSource

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

#interpret

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

#hoist

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

#eventSource

eventSource :: forall f m a. MonadAff m => ((a -> Effect Unit) -> Effect 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'

eventSource' :: forall f m a. MonadAff m => ((a -> Effect Unit) -> Effect (Effect 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_

eventSource_ :: forall f m. MonadAff m => (Effect Unit -> Effect 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_'

eventSource_' :: forall f m. MonadAff m => (Effect Unit -> Effect (Effect 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

catMaybes :: forall m a r. 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

produce :: forall a r. ((Either a r -> Effect Unit) -> Effect Unit) -> Producer a Aff r

#produce'

produce' :: forall a r. ((Either a r -> Effect Unit) -> Effect (Effect Unit)) -> Aff { producer :: Producer a Aff r, cancel :: r -> Aff Boolean }

#produceAff

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

#produceAff'

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

Modules