| Copyright | Copyright © 2019 Kadena LLC. |
|---|---|
| License | BSD-3-Clause |
| Maintainer | Colin Woodbury <colin@kadena.io> |
| Safe Haskell | None |
| Language | Haskell2010 |
Network.Wai.EventSource.Streaming
Description
Client-side consumption of the ServerEvent type from wai-extra via the
streaming ecosystem.
Synopsis
- withEvents :: Request -> Manager -> (Stream (Of ServerEvent) IO () -> IO a) -> IO a
- class FromEvent a where
- fromEvent :: ByteString -> Maybe a
- dataOnly :: (FromEvent a, Monad m) => Stream (Of ServerEvent) m r -> Stream (Of a) m r
- event :: Parser ServerEvent
ServerEvent Stream
withEvents :: Request -> Manager -> (Stream (Of ServerEvent) IO () -> IO a) -> IO a Source #
A low-level wrapper around withResponse. Provides a simple, unending
source of ServerEvents, presumably from an endpoint served via
eventSourceAppIO or otherwise.
Since: 1.0.0
Auto-conversion of ServerEvents
class FromEvent a where Source #
Convert a ServerEvent's data field into some type.
Since: 1.0.1
Methods
fromEvent :: ByteString -> Maybe a Source #
dataOnly :: (FromEvent a, Monad m) => Stream (Of ServerEvent) m r -> Stream (Of a) m r Source #
A stream of only the data fields of each consumed ServerEvent. Assumes
that each data field contains bytes of identical format, i.e. decodable by
FromEvent. Silently skips over decoding failures.