sprocket/cassette
Types
pub type CSRFValidator =
fn(String) -> Result(Nil, Nil)
pub type CassetteOpts {
CassetteOpts(debug: Bool)
}
Constructors
-
CassetteOpts(debug: Bool)
pub type Message {
Shutdown
GetState(reply_with: Subject(State))
PushSprocket(sprocket: Sprocket)
GetSprocket(
reply_with: Subject(Result(Sprocket, Nil)),
id: Unique,
)
PopSprocket(
reply_with: Subject(Result(Sprocket, Nil)),
id: Unique,
)
}
Constructors
-
Shutdown
-
GetState(reply_with: Subject(State))
-
PushSprocket(sprocket: Sprocket)
-
GetSprocket( reply_with: Subject(Result(Sprocket, Nil)), id: Unique, )
-
PopSprocket( reply_with: Subject(Result(Sprocket, Nil)), id: Unique, )
Functions
pub fn get_sprocket(ca: Subject(Message), ws: Unique) -> Result(
Subject(sprocket/sprocket.Message),
Nil,
)
Gets a sprocket from the cassette.
pub fn get_state(ca: Subject(Message)) -> State
Get the current state of the cassette. Mostly intended for unit tests and debugging.
pub fn live_message(ca: Subject(Message), id: Unique, view: Element, msg: String, ws_send: fn(
String,
) -> Result(Nil, Nil)) -> Result(Nil, Nil)
pub fn pop_sprocket(ca: Subject(Message), ws: Unique) -> Result(
Subject(sprocket/sprocket.Message),
Nil,
)
Pops a sprocket from the cassette.
pub fn push_sprocket(ca: Subject(Message), sprocket: Subject(
sprocket/sprocket.Message,
)) -> Nil
Pushes a sprocket to the cassette.
pub fn start(csrf_validator: fn(String) -> Result(Nil, Nil), opts: Option(
CassetteOpts,
)) -> Subject(Message)
Start the cassette. This is intended to only be called once during web server initiliazation.
The cassette is a long running process that manages the state of all sprockets and preflights.