Sign in

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

    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.

    Dispatch

    pub(all) type Dispatch[Msg] (Msg) -> Cmd

    Dispatch::inner

    #deprecated("Use `struct T(A)` to declare a newtype and use `.0` access the underlying type instead.")
    fn[Msg] Dispatch::inner(self : Dispatch[Msg]) -> ((Msg) -> Cmd)
    Convert newtype to its underlying type, automatically derived.

    Dispatch::map

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

    EffectKind

    pub(all) enum EffectKind {
    Immediately
    AfterRender
    }

    Scheduler

    type Scheduler

    Scheduler::add

    fn Scheduler::add(self : Scheduler, cmd : Cmd) -> Unit

    Scheduler::add_url_changed

    fn Scheduler::add_url_changed(self : Scheduler, url :
    Url
    ) -> Unit

    after_render

    let after_render : EffectKind

    attempt

    fn[A, E : Error] attempt(msg : (Result[A, E]) -> Cmd, f : async () -> A raise E) -> Cmd

    Create a command that runs an async function and handles errors.

    Similar to perform, but captures errors and passes Result[A, E] to msg.

    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

    Delay execution of a command by ms milliseconds.

    The delayed command is added back to the message queue after the timer fires.

    effect

    fn effect(f : async () -> Unit noraise) -> Cmd

    Create a command that runs an effectful async function

    immediately

    let immediately : EffectKind

    none

    let none : Cmd

    A command that does nothing.

    perform

    fn[A] perform(msg : (A) -> Cmd, f : async () -> A noraise) -> Cmd

    Create a command that runs an async function.

    The async function f is executed, then its result is converted into a new command by msg and scheduled back into the update loop.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io