README

moonbit-community/rabbita/cmd does not have a README file

#
Settle

type Settle = (Json) -> Unit

#
Context

#internal(experimental, "This API is unstable and may change in the future.")
pub(open) trait Context {
#internal(experimental, "This API is unstable and may change in the future.")
fn get_origin(Self) -> String
#internal(experimental, "This API is unstable and may change in the future.")
fn inject_url_changed(Self, String) -> Cmd
#internal(experimental, "This API is unstable and may change in the future.")
fn inject_url_request(Self, String) -> Cmd
}

#
Scheduler

pub(open) trait Scheduler : Context {
fn add(Self, Cmd) -> Unit = _
#internal(experimental, "This API is unstable and may change in the future.")
fn queue_command(Self, Cmd) -> Unit
#internal(experimental, "This API is unstable and may change in the future.")
fn set_url_changed_injector(Self, Injector[String]) -> Unit
#internal(experimental, "This API is unstable and may change in the future.")
fn set_url_request_injector(Self, Injector[String]) -> Unit
}

#
HydrateExn

#internal(experimental, "This API is unstable and may change in the future.")
pub(all) suberror HydrateExn {
Unhandled
Fallback
Skip
}

#
Unhandled

#internal(experimental, "This API is unstable and may change in the future.")
pub(all) suberror Unhandled

#
Cmd

type Cmd

A deferred command handled by the Rabbita runtime.

Cmd models side effects in the update loop. Commands are returned from update or embedded in Html event handlers, and are executed later by the runtime.
impl Debug for Cmd

#
EffectKind

pub(all) enum EffectKind {
Immediately
AfterRender
}

#
Emit

#alias(Dispatch, deprecated="Use Emit[Msg] instead.")
pub(all) struct Emit[Msg]((Msg) -> Cmd)

#
Emit::map

fn[A, B] Emit::map(self : Emit[A], f : (B) -> A) -> Emit[B]

#
Extension

#internal(experimental, "This API is unstable and may change in the future.")
pub(all) extenum Extension {
}

#
Injector

#internal(experimental, "This API is unstable and may change in the future.")
pub(all) struct Injector[Arg]((Arg) -> Cmd)

#internal(experimental, "This API is unstable and may change in the future.")
type Op

#
Op::Op

#internal(experimental, "This API is unstable and may change in the future.")
fn Op::Op() -> Op

#
Op::on_debug

#internal(experimental, "This API is unstable and may change in the future.")
fn Op::on_debug(self : Op, f : (Extension) ->
Repr
raise Unhandled) -> Unit

#
Op::on_identify

#internal(experimental, "This API is unstable and may change in the future.")
fn Op::on_identify(self : Op, identify : (Extension) -> String raise Unhandled) -> Unit

Registers the identity used to store and resume this command's SSR transcript value. Authors must return different keys for commands that may need different transcript values during hydration.

#
Op::on_invoke

#internal(experimental, "This API is unstable and may change in the future.")
fn Op::on_invoke(self : Op, f : (Extension, &Context) -> OpCont[Cmd] raise Unhandled) -> Unit

#
Op::on_resume

#internal(experimental, "This API is unstable and may change in the future.")
fn Op::on_resume(self : Op, f : (Extension, Json, &Context) -> Cmd raise HydrateExn) -> Unit

#
Op::on_settle

#internal(experimental, "This API is unstable and may change in the future.")
fn Op::on_settle(self : Op, f : (Extension, &Context) -> OpCont[(Json, Cmd)] raise Unhandled) -> Unit

#
Op::request

#internal(experimental, "This API is unstable and may change in the future.")
fn Op::request(self : Op, extension : Extension) -> Cmd

#
OpCont

#internal(experimental, "This API is unstable and may change in the future.")
pub(all) enum OpCont[T] {
None
Ready(T)
Async(async () -> T)
AfterLayout(() -> T)
LegacyEffect(EffectKind, (&Scheduler) -> Unit)
}

#
Runner

#internal(experimental, "This API is unstable and may change in the future.")
type Runner

#
Runner::identify

#internal(experimental, "This API is unstable and may change in the future.")
fn Runner::identify(runner : Runner, extension : Extension) -> String raise Unhandled

#
Runner::invoke

#internal(experimental, "This API is unstable and may change in the future.")
fn Runner::invoke(runner : Runner, extension : Extension, context : &Context) -> OpCont[Cmd] raise Unhandled

#
Runner::resume_

#internal(experimental, "This API is unstable and may change in the future.")
fn Runner::resume_(runner : Runner, extension : Extension, value : Json, context : &Context) -> Cmd raise HydrateExn

#
Runner::settle

#internal(experimental, "This API is unstable and may change in the future.")
fn Runner::settle(runner : Runner, extension : Extension, context : &Context) -> OpCont[(Json, Cmd)] raise Unhandled

#
after_render

let after_render : EffectKind

#
batch

fn batch(cmds : Array[Cmd]) -> Cmd

Combine multiple commands into one command.

#
custom_cmd

#alias(raw_effect, deprecated="`raw_effect` is deprecated, use `custom_cmd` instead")
fn custom_cmd(callback : (&Scheduler) -> Unit, kind? : EffectKind) -> Cmd

Create a low-level effect command for runtime and FFI integration. Consider use higher-level helpers like perform, delay, @http.post(), and @dialog.show() in app code.

This function allows you to write wrappers that encapsulate FFI in a command when the functionality is not provided by Rabbita yet.

Parameters:

  • callback: receives the runtime Scheduler, so it can enqueue follow-up commands (for example, after an async callback).

  • kind: determines when the effect runs.
    • Immediately: run as soon as the runtime receives it.
    • AfterRender: run after DOM patching for the current flush completes.

Example:

extern "js" fn set_timeout(f : () -> Unit, ms : Int) = "(f,ms) => setTimeout(f, ms)"

pub fn delay(cmd : Cmd, ms : Int) -> Cmd {
raw_effect(scheduler => set_timeout(() => scheduler.add(cmd), ms))
}

#
delay

fn delay(cmd : Cmd, ms : Int) -> Cmd

#
immediately

let immediately : EffectKind

#
none

let none : Cmd

A command that does nothing.

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io