sprocket/sprocket

Types

pub type Message {
  Shutdown
  GetRendered(reply_with: Subject(Option(RenderedElement)))
  HasWebSocket(reply_with: Subject(Bool), websocket: WebSocket)
  SetRenderUpdate(fn() -> Nil)
  Render(reply_with: Subject(RenderedElement))
  RenderUpdate
  SetUpdateHook(fn(Unique, fn(Hook) -> Hook) -> Nil)
  UpdateHook(Unique, fn(Hook) -> Hook)
  GetEventHandler(
    reply_with: Subject(Result(EventHandler, Nil)),
    id: Unique,
  )
}

Constructors

  • Shutdown
  • GetRendered(reply_with: Subject(Option(RenderedElement)))
  • HasWebSocket(reply_with: Subject(Bool), websocket: WebSocket)
  • SetRenderUpdate(fn() -> Nil)
  • Render(reply_with: Subject(RenderedElement))
  • RenderUpdate
  • SetUpdateHook(fn(Unique, fn(Hook) -> Hook) -> Nil)
  • UpdateHook(Unique, fn(Hook) -> Hook)
  • GetEventHandler(
      reply_with: Subject(Result(EventHandler, Nil)),
      id: Unique,
    )
pub type Sprocket =
  Subject(Message)

Functions

pub fn get_handler(actor: Subject(Message), id: String) -> Result(
  EventHandler,
  Nil,
)

Get the event handler for a given id

pub fn get_rendered(actor: Subject(Message)) -> Option(
  RenderedElement,
)

Get the previously rendered view from the actor

pub fn has_websocket(actor: Subject(Message), websocket: Subject(
    HandlerMessage,
  )) -> Bool

Returns true if the actor matches a given websocket connection

pub fn render(actor: Subject(Message)) -> RenderedElement

Render the view

pub fn render_update(actor: Subject(Message)) -> Nil

Render the view and send an update Patch to the updater

pub fn start(ws: Option(Subject(HandlerMessage)), view: Option(
    Element,
  ), updater: Option(Updater(Patch))) -> Subject(Message)

Start a new sprocket actor

pub fn stop(actor: Subject(Message)) -> Nil

Stop a sprocket actor

Search Document