omnimessage_lustre/transports
Types
pub type Transport(encoding, decode_error) {
Transport(
listen: fn(TransportHandlers(encoding, decode_error)) -> Nil,
send: fn(encoding, TransportHandlers(encoding, decode_error)) ->
Nil,
)
}
Constructors
-
Transport( listen: fn(TransportHandlers(encoding, decode_error)) -> Nil, send: fn(encoding, TransportHandlers(encoding, decode_error)) -> Nil, )
This represents an error in the transport itself (e.g, loss of connection),
sent inside a TransportError
record.
Note that this isn’t for error handling of your app logic, use omnimessage messages for that.
pub type TransportError(decode_error) {
InitError(message: String)
DecodeError(decode_error)
SendError(message: String)
}
Constructors
-
InitError(message: String)
-
DecodeError(decode_error)
-
SendError(message: String)
Represents the handlers a transport uses for communication. Unless you’re building a transport, you don’t need to know about this.
pub type TransportHandlers(encoding, decode_error) {
TransportHandlers(
on_up: fn() -> Nil,
on_down: fn(Int, String) -> Nil,
on_message: fn(encoding) -> Nil,
on_error: fn(TransportError(decode_error)) -> Nil,
)
}
Constructors
-
TransportHandlers( on_up: fn() -> Nil, on_down: fn(Int, String) -> Nil, on_message: fn(encoding) -> Nil, on_error: fn(TransportError(decode_error)) -> Nil, )
This type represents the state messages sent to your Lustre application via the wrapper you gave on application creation.
It allows you to do housekeeping such as init calls, online/offline inidcators, and debugging.
pub type TransportState(decode_error) {
TransportUp
TransportDown(code: Int, message: String)
TransportError(TransportError(decode_error))
}
Constructors
-
TransportUp
-
TransportDown(code: Int, message: String)
-
TransportError(TransportError(decode_error))
Functions
pub fn http(
path path: String,
method method: Option(Method),
headers headers: Dict(String, String),
) -> Transport(String, a)
An http transport using text requests