sprocket
Types
pub type CSRFValidator =
fn(String) -> Result(Nil, Nil)
pub type Response {
Joined(spkt: Sprocket)
Empty
}
Constructors
-
Joined(spkt: Sprocket)
-
Empty
pub type Sprocket {
Sprocket(
runtime: Option(Runtime),
view: Element,
ws_send: WSSend,
csrf_validator: CSRFValidator,
opts: Option(SprocketOpts),
)
}
Constructors
-
Sprocket( runtime: Option(Runtime), view: Element, ws_send: WSSend, csrf_validator: CSRFValidator, opts: Option(SprocketOpts), )
pub type SprocketOpts {
SprocketOpts(debug: Bool)
}
Constructors
-
SprocketOpts(debug: Bool)
Functions
pub fn cleanup(spkt: Sprocket) -> Option(Nil)
Cleanup a sprocket. This function is called when a websocket is closed. It will find the sprocket that is associated with the websocket and stop it.
Its important to call this function when the websocket connection is terminated.
pub fn handle_ws(
spkt: Sprocket,
msg: String,
) -> Result(Response, String)
Handle a message from the websocket. This function is called when a message is received from the websocket. It will find the sprocket that is associated with the websocket and pass the message to the sprocket. The sprocket will then handle the message and send a response back to the websocket.
pub fn new(
view: Element,
ws_send: fn(String) -> Result(Nil, Nil),
csrf_validator: fn(String) -> Result(Nil, Nil),
opts: Option(SprocketOpts),
) -> Sprocket
pub fn render_html(el: Element) -> String