Derive Macro Atom

Source
#[derive(Atom)]
{
    // Attributes available to this derive:
    #[bounce]
}
Expand description

A simple state that is Copy-on-Write and notifies registered hooks when prev_value != next_value.

It can be derived for any state that implements PartialEq + Default.

ยงExample

use std::rc::Rc;
use bounce::prelude::*;
use yew::prelude::*;

#[derive(PartialEq, Atom)]
struct Username {
    inner: String,
}

impl Default for Username {
    fn default() -> Self {
        Self {
            inner: "Jane Doe".into(),
        }
    }
}

See: use_atom