| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Yesod.EventSource
Description
This module contains everything that you need to support server-sent events in Yesod applications.
Synopsis
- repEventSource :: (EventSourcePolyfill -> ConduitT () ServerEvent (HandlerFor site) ()) -> HandlerFor site TypedContent
- pollingEventSource :: s -> (EventSourcePolyfill -> s -> HandlerFor site ([ServerEvent], s)) -> HandlerFor site TypedContent
- ioToRepEventSource :: s -> (EventSourcePolyfill -> s -> IO ([ServerEvent], s)) -> HandlerFor site TypedContent
- data EventSourcePolyfill
Documentation
repEventSource :: (EventSourcePolyfill -> ConduitT () ServerEvent (HandlerFor site) ()) -> HandlerFor site TypedContent Source #
Returns a Server-Sent Event stream from a Source of
ServerEvents. The HTTP socket is flushed after every
event. The connection is closed either when the Source
finishes outputting data or a CloseEvent is outputted,
whichever comes first.
pollingEventSource :: s -> (EventSourcePolyfill -> s -> HandlerFor site ([ServerEvent], s)) -> HandlerFor site TypedContent Source #
Return a Server-Sent Event stream given a HandlerFor action
that is repeatedly called. A state is threaded for the action
so that it may avoid using IORefs. The HandlerFor action
may sleep or block while waiting for more data. The HTTP
socket is flushed after every list of simultaneous events.
The connection is closed as soon as an CloseEvent is
outputted, after which no other events are sent to the client.
ioToRepEventSource :: s -> (EventSourcePolyfill -> s -> IO ([ServerEvent], s)) -> HandlerFor site TypedContent Source #
Return a Server-Sent Event stream given an IO action that
is repeatedly called. A state is threaded for the action so
that it may avoid using IORefs. The IO action may sleep
or block while waiting for more data. The HTTP socket is
flushed after every list of simultaneous events. The
connection is closed as soon as an CloseEvent is
outputted, after which no other events are sent to the client.
data EventSourcePolyfill Source #
Which EventSource polyfill was detected (if any).
Constructors
| NoESPolyfill | We didn't detect any |
| Remy'sESPolyfill | See https://github.com/remy/polyfills/blob/master/EventSource.js. In order to support Remy's polyfill, your server needs to explicitly close the connection from time to time--browsers such as IE7 will not show any event until the connection is closed. |