Trait respo::RespoApp

source ·
pub trait RespoApp {
    type Model: RespoStore + Debug + Clone + PartialEq + 'static;
    type Action: Debug + Clone + RespoAction + 'static;

    // Required methods
    fn dispatch(
        store: &mut RefMut<'_, Self::Model>,
        action: Self::Action
    ) -> Result<(), String>;
    fn get_mount_target(&self) -> &Node;
    fn get_store(&self) -> Rc<RefCell<Self::Model>>;
    fn get_memo_caches(&self) -> MemoCache<RespoNode<Self::Action>>;
    fn view(
        store: Ref<'_, Self::Model>,
        memo_caches: MemoCache<RespoNode<Self::Action>>
    ) -> Result<RespoNode<Self::Action>, String>;

    // Provided methods
    fn get_loop_delay() -> Option<i32> { ... }
    fn render_loop(&self) -> Result<(), String> { ... }
}
Expand description

A template for a Respo app

Required Associated Types§

source

type Model: RespoStore + Debug + Clone + PartialEq + 'static

a type of the store, with a place for states tree

source

type Action: Debug + Clone + RespoAction + 'static

actions should include one for updating states tree

Required Methods§

source

fn dispatch( store: &mut RefMut<'_, Self::Model>, action: Self::Action ) -> Result<(), String>

simulating pure function updates to the model, but actually it’s mutations

source

fn get_mount_target(&self) -> &Node

bridge to mount target

source

fn get_store(&self) -> Rc<RefCell<Self::Model>>

bridge to store

source

fn get_memo_caches(&self) -> MemoCache<RespoNode<Self::Action>>

bridge to memo caches

source

fn view( store: Ref<'_, Self::Model>, memo_caches: MemoCache<RespoNode<Self::Action>> ) -> Result<RespoNode<Self::Action>, String>

DSL for building a view

Provided Methods§

source

fn get_loop_delay() -> Option<i32>

default interval in milliseconds, by default 100ms, pass None to use raq directly, pass Some(200) to redice cost

source

fn render_loop(&self) -> Result<(), String>

start a requestAnimationFrame loop for rendering updated store

Implementors§