wip: move examples around
This commit is contained in:
1 parent
d298b626d3
commit
1e6e5e611b
86 files changed
+160
-216
No files matched your search
@@ -1,52 +0,0 @@
|
||||
fn main() {}
|
||||
|
||||
// struct CompState {
|
||||
// tasks: Vec<()>,
|
||||
// }
|
||||
// enum Actions {
|
||||
// Add,
|
||||
// MoveUp,
|
||||
// MoveDown,
|
||||
// Remvoe,
|
||||
// }
|
||||
|
||||
// static Component: FC<()> = |(cx, props)|{
|
||||
// let (tasks, dispatch) = use_reducer(
|
||||
// cx,
|
||||
// || CompState { tasks: Vec::new() },
|
||||
// |state, action: Actions| match action {
|
||||
// Actions::Add => state,
|
||||
// Actions::MoveUp => state,
|
||||
// Actions::MoveDown => state,
|
||||
// Actions::Remvoe => state,
|
||||
// },
|
||||
// );
|
||||
|
||||
// let tasklist = { (0..10).map(|f| html! { <li></li> }) }.collect::<Vec<_>>();
|
||||
|
||||
// html! {
|
||||
// <div>
|
||||
// <div>
|
||||
// <h1>"Tasks: "</h1>
|
||||
// <ul>
|
||||
// {tasklist}
|
||||
// </ul>
|
||||
// </div>
|
||||
// <div>
|
||||
// <button onclick=|_| dispatch(Action::Add)>{"Add"}</button>
|
||||
// <button onclick=|_| dispatch(Action::MoveUp)>{"MoveUp"}</button>
|
||||
// <button onclick=|_| dispatch(Action::MoveDown)>{"MoveDown"}</button>
|
||||
// <button onclick=|_| dispatch(Action::Remvoe)>{"Remvoe"}</button>
|
||||
// </div>
|
||||
// </div>
|
||||
// }
|
||||
// };
|
||||
|
||||
// fn use_reducer<Props, State, Action>(
|
||||
// cx: &mut Context<Props>,
|
||||
// init: fn() -> State,
|
||||
// reducer: fn(State, Action) -> State,
|
||||
// ) -> (State, impl Fn(Action)) {
|
||||
// let ii = init();
|
||||
// (ii, |_| {})
|
||||
// }
|
||||
@@ -1 +0,0 @@
|
||||
fn main() {}
|
||||
@@ -126,7 +126,7 @@ impl<'a, T: 'static> UseSharedState<'a, T> {
|
||||
///
|
||||
///
|
||||
/// TODO: We prevent unncessary notifications only in the hook, but we should figure out some more global lock
|
||||
pub fn write(&mut self) -> RefMut<'_, T> {
|
||||
pub fn write(&self) -> RefMut<'_, T> {
|
||||
self.cx.needs_update();
|
||||
self.notify_consumers();
|
||||
self.value.borrow_mut()
|
||||
|
||||
@@ -102,7 +102,7 @@ impl<'a, T: 'static> UseState<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set(&mut self, new_val: T) {
|
||||
pub fn set(&self, new_val: T) {
|
||||
*self.inner.wip.borrow_mut() = Some(new_val);
|
||||
self.needs_update();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user