Skip to main content

velox_core/
lib.rs

1pub mod ergonomics;
2pub mod lifecycle;
3pub mod next_tick;
4pub mod provide_inject;
5pub mod ref_cell;
6pub mod signal;
7pub mod vmodel;
8pub mod watch;
9
10// Re-export ergonomics for convenient access
11pub use ergonomics::*;
12
13// Re-export lifecycle hooks for convenient access.
14// Each `on_*` function pairs with a same-named `#[macro_export]` macro at the
15// crate root (e.g. `velox_core::on_mounted!`), so SFC `<script setup>` blocks
16// can call either the function or macro form.
17pub use lifecycle::{
18    LifecycleHandle, before_destroy, cleanup_component, clear_current_component,
19    clear_updated_hooks, current_component_id, generate_component_id, has_updated_hooks,
20    on_mounted, on_unmounted, on_updated, run_all_destroy_hooks, run_all_mounted_hooks,
21    run_all_updated_hooks, run_destroy_hooks, run_mounted_hooks, run_unmounted_hooks,
22    run_updated_hooks, set_current_component,
23};
24
25/// Create a Signal with an initial value.
26/// Usage: `let count = signal!(count = 0);`
27#[macro_export]
28macro_rules! signal {
29    ($name:ident = $value:expr) => {
30        std::rc::Rc::new($crate::signal::Signal::new($value))
31    };
32}
33
34/// Create a Vue-like reactive reference.
35/// Usage: `let count = ref!(0);`
36/// Expands to: `velox_core::ref_value(0)`
37#[macro_export]
38macro_rules! r#ref {
39    ($value:expr) => {
40        $crate::ergonomics::ref_value($value)
41    };
42}
43
44/// Create a shallow reactive reference for Copy types.
45/// Usage: `let count = shallow!(0);`
46#[macro_export]
47macro_rules! shallow {
48    ($value:expr) => {
49        $crate::ergonomics::shallow_ref($value)
50    };
51}