XiLaiTL/moobile/vendor/rabbita/cmd does not have a README file
#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
}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
}#internal(experimental, "This API is unstable and may change in the future.")
pub(all) suberror HydrateExn {
Unhandled
Fallback
Skip
}#internal(experimental, "This API is unstable and may change in the future.")
pub(all) suberror Unhandledtype Cmd#internal(experimental, "This API is unstable and may change in the future.")
pub(all) extenum Extension {
}#external
pub type HostCapabilityMOBILE_HOST.native = {
visibility: {
// 订阅一个布尔流;返回退订函数
subscribe(cb) {
const sub = AppState.addEventListener("change", s => cb(s !== "active"));
return () => sub.remove();
},
},
}match @cmd.host_capability("visibility") {
Some(cap) => cap.subscribe_bool(...) // 宿主实现(RN)
None => ...原有的 DOM 实现... // 回退(Web)
}fn HostCapability::subscribe_json(self : HostCapability, cb : (String) -> Unit) -> HostSubscription?| 方案 | 代价 |
|---|---|
| 每种形状一个窄适配器(subscribe_vec2 / subscribe_scroll / …) | FFI 面按载荷数量线性膨胀,每加一条能力都要动库 |
| JSON 字符串(本方案) | 形状错误在编译期看不见 —— 用"解码严格"补(见下) |
| 不透明 @js.Value 交给能力包自己打字 | 每个能力包都要写一遍 JS 互操作,且要 import @js |
#external
pub type HostSubscription#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#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)
}#internal(experimental, "This API is unstable and may change in the future.")
type Runner#alias(raw_effect, deprecated="`raw_effect` is deprecated, use `custom_cmd` instead")
fn custom_cmd(callback : (&Scheduler) -> Unit, kind? : EffectKind) -> Cmdextern "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))
}fn host_has_dom() -> Bool| 问题 | 谁来答 | |
|---|---|---|
| host_capability(name) | 这个能力你有替代实现吗? | 宿主登记 |
| host_has_dom() | 这个运行时是不是浏览器? | 运行时事实,不需要谁声明 |
Install
Download zipMoonBit UI for mobile: Android, iOS and Web from one rabbita (TEA) app, rendered by React Native
Dependencies