sprocket/socket

Types

pub type ComponentHooks =
  OrderedMap(Int, Hook)
pub type ComponentWip {
  ComponentWip(
    hooks: ComponentHooks,
    index: Int,
    is_first_render: Bool,
  )
}

Constructors

  • ComponentWip(
      hooks: ComponentHooks,
      index: Int,
      is_first_render: Bool,
    )
pub type EventHandler {
  EventHandler(id: Unique, handler: CallbackFn)
}

Constructors

  • EventHandler(id: Unique, handler: CallbackFn)
pub type Socket {
  Socket(
    wip: ComponentWip,
    handlers: List(EventHandler),
    ws: Option(WebSocket),
    render_update: fn() -> Nil,
  )
}

Constructors

  • Socket(
      wip: ComponentWip,
      handlers: List(EventHandler),
      ws: Option(WebSocket),
      render_update: fn() -> Nil,
    )
pub type Updater(r) {
  Updater(send: fn(r) -> Result(Nil, Nil))
}

Constructors

  • Updater(send: fn(r) -> Result(Nil, Nil))
pub type WebSocket =
  Subject(HandlerMessage)

Functions

pub fn fetch_or_init_hook(socket: Socket, init: fn() -> Hook) -> #(
  Socket,
  Hook,
  Int,
)
pub fn get_event_handler(socket: Socket, id: Unique) -> #(
  Socket,
  Result(EventHandler, Nil),
)
pub fn new(ws: Option(Subject(HandlerMessage))) -> Socket
pub fn push_event_handler(socket: Socket, identifiable_cb: IdentifiableCallback) -> #(
  Socket,
  Unique,
)
pub fn reset_for_render(socket: Socket) -> Socket
pub fn update_hook(socket: Socket, hook: Hook, index: Int) -> Socket
Search Document