Skip to main content

fusor/
lib.rs

1//! Reactive Rust for HTML script blocks, compiled by Cargo without a Rust DSL.
2//!
3//! ```
4//! use fusor::{signal, derived, effect, batch};
5//! let count = signal(0);
6//! let doubled = derived({ let count = count.clone(); move || count.get() * 2 });
7//! let subscription = effect(move || println!("{}", doubled.get()));
8//! batch(|| { count.set(2); count.set(3); });
9//! // Prints 0, then 6. Dropping the subscription stops it.
10//! drop(subscription);
11//! ```
12
13#[doc(hidden)]
14pub mod authoring;
15pub mod bind;
16mod cleanup;
17pub mod coherence;
18mod owner;
19mod reactive;
20pub use cleanup::{Cleanup, CleanupEffect, effect_with_cleanup};
21pub use owner::{ContextError, ContextKey, Owner, OwnerHandle, Registration};
22#[doc(hidden)]
23pub use reactive::versions;
24
25/// Versioned contract shared by the HTML compiler and the DOM runtime.
26/// This is an implementation interface, not application authoring syntax.
27#[doc(hidden)]
28pub mod template;
29pub use reactive::{
30    Derived, Effect, Memo, Signal, batch, derived, effect, memo, memo_with_eq, signal, untrack,
31};
32
33#[cfg(feature = "dom")]
34pub mod dom;
35
36#[cfg(feature = "dom")]
37pub use dom::FromInputs;
38#[cfg(feature = "dom")]
39pub use fusor_macros::FromInputs;
40
41#[cfg(feature = "javascript")]
42pub mod js;
43#[cfg(feature = "javascript")]
44pub use fusor_macros::JsInputs;
45#[cfg(feature = "javascript")]
46pub use js::JsInputs;
47
48/// The small set of types needed by a browser application.
49pub mod prelude {
50    #[cfg(feature = "dom")]
51    pub use crate::FromInputs;
52    #[cfg(feature = "javascript")]
53    pub use crate::JsInputs;
54    #[cfg(feature = "dom")]
55    pub use crate::dom::{Component, Content, Scope, TemplateComponent, document, element};
56    pub use crate::{Cleanup, CleanupEffect, effect_with_cleanup};
57    pub use crate::{ContextError, ContextKey, Owner, OwnerHandle};
58    pub use crate::{
59        Derived, Effect, Memo, Signal, batch, derived, effect, memo, memo_with_eq, signal, untrack,
60    };
61}