| Copyright | (C) 2016-2025 David M. Johnson |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <code@dmj.io> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Miso.EventSource
Description
Functions and types for working with Server Sent Events
Synopsis
- connectText :: URL -> (EventSource -> action) -> (MisoString -> action) -> (MisoString -> action) -> Effect parent model action
- connectJSON :: FromJSON value => URL -> (EventSource -> action) -> (value -> action) -> (MisoString -> action) -> Effect parent model action
- close :: EventSource -> Effect parent model action
- socketState :: WebSocket -> (SocketState -> action) -> Effect parent model action
- emptyEventSource :: EventSource
- newtype EventSource = EventSource Int
- type URL = MisoString
- data Payload value
- = JSON value
- | BLOB Blob
- | TEXT MisoString
- | BUFFER ArrayBuffer
EventSource
Arguments
| :: URL | |
| -> (EventSource -> action) | onOpen |
| -> (MisoString -> action) | onMessage |
| -> (MisoString -> action) | onError |
| -> Effect parent model action |
Arguments
| :: FromJSON value | |
| => URL | |
| -> (EventSource -> action) | onOpen |
| -> (value -> action) | onMessage |
| -> (MisoString -> action) | onError |
| -> Effect parent model action |
close :: EventSource -> Effect parent model action Source #
socketState :: WebSocket -> (SocketState -> action) -> Effect parent model action Source #
Defaults
emptyEventSource :: EventSource Source #
A null EventSource is one with a negative descriptor.
Types
newtype EventSource Source #
A type for holding an EventSource descriptor.
Constructors
| EventSource Int |
Instances
| Num EventSource Source # | |
Defined in Miso.Runtime Methods (+) :: EventSource -> EventSource -> EventSource # (-) :: EventSource -> EventSource -> EventSource # (*) :: EventSource -> EventSource -> EventSource # negate :: EventSource -> EventSource # abs :: EventSource -> EventSource # signum :: EventSource -> EventSource # fromInteger :: Integer -> EventSource # | |
| Eq EventSource Source # | |
Defined in Miso.Runtime | |
| ToJSVal EventSource Source # | |
Defined in Miso.Runtime Methods toJSVal :: EventSource -> JSM JSVal Source # toJSValListOf :: [EventSource] -> JSM JSVal Source # | |
type URL = MisoString Source #
URL that the WebSocket will connect to
Re-exports
Payload is used as the potential source of data when working with EventSource
Constructors
| JSON value | JSON-encoded data |
| BLOB Blob | Binary encoded data |
| TEXT MisoString | Text encoded data |
| BUFFER ArrayBuffer | Buffered data |