Module

Specular.FRP.Async

Package
purescript-specular
Repository
restaumatic/purescript-specular

#startAff Source

startAff :: forall m. MonadFRP m => Aff Unit -> m Unit

Start an asynchronous Aff computation. It will be cancelled on cleanup.

#fromLoaded Source

fromLoaded :: forall a. RequestState a -> Maybe a

#asyncRequestMaybe Source

asyncRequestMaybe :: forall m a. MonadEffect m => MonadFRP m => Dynamic (Maybe (Aff a)) -> m (Dynamic (RequestState a))

On each observed value of the Dynamic,

  • if it's Nothing, the resulting Dynamic will have value NotRequested.

  • if it's a Just, the contents will be executes asynchronously and the resulting Dynamic will obtain value Loaded x. During the request execution the result Dynamic will have value Loading.

    If the input Dynamic changes value while a request is in progress, it will be cancelled using Aff's (Aff's) cancellation mechanism. This ensures that the value of the resulting Dynamic will eventually be that of the most recent value of the input Dynamic, independent of the order of arrival of the responses.

#asyncRequest Source

asyncRequest :: forall m a. MonadEffect m => MonadFRP m => Dynamic (Aff a) -> m (Dynamic (RequestState a))

Like asyncRequestMaybe, but without the Nothing case.

#performEvent Source

performEvent :: forall m a. MonadFRP m => Event (Aff a) -> m (Event a)

Run asynchronous action when an Event occurs. The returned Event will fire when such an action completes.

Note: the results may arrive in a different order than the requests.