pub trait RespoApp {
type Model: RespoStore + Debug + Clone + PartialEq + 'static;
type Action: Debug + Clone + RespoAction + 'static;
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>;
fn get_loop_delay() -> Option<i32> { ... }
fn render_loop(&self) -> Result<(), String> { ... }
}
Expand description
A template for a Respo app
Required Associated Types§
sourcetype Model: RespoStore + Debug + Clone + PartialEq + 'static
type Model: RespoStore + Debug + Clone + PartialEq + 'static
a type of the store, with a place for states tree
sourcetype Action: Debug + Clone + RespoAction + 'static
type Action: Debug + Clone + RespoAction + 'static
actions should include one for updating states tree
Required Methods§
sourcefn dispatch(
store: &mut RefMut<'_, Self::Model>,
action: Self::Action
) -> Result<(), String>
fn dispatch(
store: &mut RefMut<'_, Self::Model>,
action: Self::Action
) -> Result<(), String>
simulating pure function updates to the model, but actually it’s mutations
sourcefn get_mount_target(&self) -> &Node
fn get_mount_target(&self) -> &Node
bridge to mount target
sourcefn get_memo_caches(&self) -> MemoCache<RespoNode<Self::Action>>
fn get_memo_caches(&self) -> MemoCache<RespoNode<Self::Action>>
bridge to memo caches
Provided Methods§
sourcefn get_loop_delay() -> Option<i32>
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
sourcefn render_loop(&self) -> Result<(), String>
fn render_loop(&self) -> Result<(), String>
start a requestAnimationFrame loop for rendering updated store