Remove argument from use_hook closure (#496)

Also; update docs for said function
This commit is contained in:
Reinis Mazeiks authored and GitHub committed 2022-07-11 15:50:56 -04:00
1 parent 6ea076fa7f
commit d734dc5b46
29 files changed
+53 -55

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ use std::{
pub fn use_atom_ref<T: 'static>(cx: &ScopeState, atom: AtomRef<T>) -> &UseAtomRef<T> {
let root = use_atom_root(cx);
&cx.use_hook(|_| {
&cx.use_hook(|| {
root.initialize(atom);
(
UseAtomRef {
+1 -1
View File
@@ -4,7 +4,7 @@ use std::rc::Rc;
// Returns the atom root, initiaizing it at the root of the app if it does not exist.
pub fn use_atom_root(cx: &ScopeState) -> &Rc<AtomRoot> {
cx.use_hook(|_| match cx.consume_context::<Rc<AtomRoot>>() {
cx.use_hook(|| match cx.consume_context::<Rc<AtomRoot>>() {
Some(root) => root,
None => cx.provide_root_context(Rc::new(AtomRoot::new(cx.schedule_update_any()))),
})
+1 -1
View File
@@ -4,7 +4,7 @@ use std::rc::Rc;
// Initializes the atom root and retuns it;
pub fn use_init_atom_root(cx: &ScopeState) -> &Rc<AtomRoot> {
cx.use_hook(|_| match cx.consume_context::<Rc<AtomRoot>>() {
cx.use_hook(|| match cx.consume_context::<Rc<AtomRoot>>() {
Some(ctx) => ctx,
None => cx.provide_context(Rc::new(AtomRoot::new(cx.schedule_update_any()))),
})
+1 -1
View File
@@ -22,7 +22,7 @@ pub fn use_read_rc<V: 'static>(cx: &ScopeState, f: impl Readable<V>) -> &Rc<V> {
}
}
let inner = cx.use_hook(|_| UseReadInner {
let inner = cx.use_hook(|| UseReadInner {
value: None,
root: root.clone(),
scope_id: cx.scope_id(),
+1 -1
View File
@@ -4,7 +4,7 @@ use std::rc::Rc;
pub fn use_set<T: 'static>(cx: &ScopeState, f: impl Writable<T>) -> &Rc<dyn Fn(T)> {
let root = use_atom_root(cx);
cx.use_hook(|_| {
cx.use_hook(|| {
let id = f.unique_id();
let root = root.clone();
root.initialize(f);
+1 -1
View File
@@ -33,7 +33,7 @@ use std::{
pub fn use_atom_state<T: 'static>(cx: &ScopeState, f: impl Writable<T>) -> &AtomState<T> {
let root = crate::use_atom_root(cx);
let inner = cx.use_hook(|_| AtomState {
let inner = cx.use_hook(|| AtomState {
value: None,
root: root.clone(),
scope_id: cx.scope_id(),