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

    Hook

    type Hook[Arg] = (&Scheduler, Arg) -> Unit

    Scheduler

    pub(open) trait Scheduler {
    fn run_effect(Self, EffectKind, (&Scheduler) -> Unit) -> Unit
    fn queue_message(Self,
    Id
    ,
    Any
    ) -> Unit
    fn drain_message(Self) -> Unit
    fn add(Self, Cmd) -> Unit = _
    fn hooks(Self) -> Hooks
    }

    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.

    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]

    Hooks

    pub(all) struct Hooks {
    url_request : (&Scheduler, String) -> Unit?
    url_changed : (&Scheduler, String) -> Unit?
    }

    Path

    pub(all) enum Path {
    Index(Int, Path)
    Keyed(String, Path)
    Root
    } derive(Compare, Eq, Hash)

    A position in an indexed or keyed runtime tree.

    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))
    }

    immediately

    let immediately : EffectKind

    none

    let none : Cmd

    A command that does nothing.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io