sprocket/sprocket

Types

pub type Message {
  Shutdown
  SetSelf(Sprocket)
  BeginSelfDestruct(Int)
  CancelSelfDestruct
  GetRendered(reply_with: Subject(Option(RenderedElement)))
  GetId(reply_with: Subject(Unique))
  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,
  )
  GetClientHook(
    reply_with: Subject(Result(Hook, Nil)),
    id: Unique,
  )
}

Constructors

  • Shutdown
  • SetSelf(Sprocket)
  • BeginSelfDestruct(Int)
  • CancelSelfDestruct
  • GetRendered(reply_with: Subject(Option(RenderedElement)))
  • GetId(reply_with: Subject(Unique))
  • 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,
    )
  • GetClientHook(reply_with: Subject(Result(Hook, Nil)), id: Unique)
pub type Sprocket =
  Subject(Message)

Functions

pub fn get_client_hook(actor: Subject(Message), id: String) -> Result(
  Hook,
  Nil,
)

Get the client hook for a given id

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

Get the event handler for a given id

pub fn get_id(actor: Subject(Message)) -> Result(Unique, Nil)

Returns true if the actor matches a given websocket connection

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

Get the previously rendered view from the actor

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(id: Unique, view: Element, updater: Option(
    Updater(Patch),
  ), dispatcher: Option(Dispatcher)) -> Subject(Message)

Start a new sprocket actor

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

Stop a sprocket actor

Search Document