Why there are so many state methods? #32
Replies: 3 comments 3 replies
-
|
Have you checked the Blinc Book chapter on State Management yet? |
Beta Was this translation helpful? Give feedback.
-
|
@ansarizafar Please join the newly created Discord server, and repost your query in the #help channel. So that it's easier to follow up. https://discord.gg/NPRzChSm |
Beta Was this translation helpful? Give feedback.
-
|
You would mostly want to use Now to answer your question, the 10 methods you listed are constructors for two underlying types, called from different places:
Plain reactive valuesInside let count = ctx.use_state_keyed("count", || 0i32);
button("inc").on_click(move |_| count.set(count.get() + 1))Inside reusable widget code, no use blinc_core::use_state_keyed;
let page = use_state_keyed("pagination_page", || 1usize);The free function delegates to a process-global Inside Blinc widget internals (you'll see this all over let handle = BlincContextState::get().use_state_keyed(&self.key.derive("handle"), || None);Same call as the free function, just spelled out. For mutating an existing BlincContextState::get().update(count, |v| v - 1);Most app code uses Avoid these unless you really mean it: let count = ctx.use_signal(0); // creates a new signal every build_ui call
let count = ctx.use_signal_keyed("c", || 0); // same as use_state_keyed but lower level
FSM widget state (
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
There are so many methods for creating state and no information is available about their use
Blinc_cn is using use_state without context
we also have
and #[state] macro
I am really confused where to use which method. Please help me understand.
Beta Was this translation helpful? Give feedback.
All reactions