mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 14:54:16 +00:00
Replace with_scope_property with push_scope_property
Avoids duplicate codegen
This commit is contained in:
parent
5d6a083d1d
commit
b1b9853f92
5 changed files with 9 additions and 12 deletions
|
@ -66,7 +66,7 @@ where
|
|||
if #[cfg(not(feature = "ssr"))] {
|
||||
let e = cx.runtime.create_effect(f);
|
||||
//eprintln!("created effect {e:?}");
|
||||
cx.with_scope_property(|prop| prop.push(ScopeProperty::Effect(e)))
|
||||
cx.push_scope_property(ScopeProperty::Effect(e))
|
||||
} else {
|
||||
// clear warnings
|
||||
_ = cx;
|
||||
|
@ -121,7 +121,7 @@ pub fn create_isomorphic_effect<T>(
|
|||
{
|
||||
let e = cx.runtime.create_effect(f);
|
||||
//eprintln!("created effect {e:?}");
|
||||
cx.with_scope_property(|prop| prop.push(ScopeProperty::Effect(e)))
|
||||
cx.push_scope_property(ScopeProperty::Effect(e))
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
|
|
|
@ -216,7 +216,7 @@ where
|
|||
}
|
||||
});
|
||||
|
||||
cx.with_scope_property(|prop| prop.push(ScopeProperty::Resource(id)));
|
||||
cx.push_scope_property(ScopeProperty::Resource(id));
|
||||
|
||||
Resource {
|
||||
runtime: cx.runtime,
|
||||
|
@ -339,7 +339,7 @@ where
|
|||
move |_| r.load(false)
|
||||
});
|
||||
|
||||
cx.with_scope_property(|prop| prop.push(ScopeProperty::Resource(id)));
|
||||
cx.push_scope_property(ScopeProperty::Resource(id));
|
||||
|
||||
Resource {
|
||||
runtime: cx.runtime,
|
||||
|
|
|
@ -290,14 +290,11 @@ impl Scope {
|
|||
})
|
||||
}
|
||||
|
||||
pub(crate) fn with_scope_property(
|
||||
&self,
|
||||
f: impl FnOnce(&mut Vec<ScopeProperty>),
|
||||
) {
|
||||
pub(crate) fn push_scope_property(&self, prop: ScopeProperty) {
|
||||
_ = with_runtime(self.runtime, |runtime| {
|
||||
let scopes = runtime.scopes.borrow();
|
||||
if let Some(scope) = scopes.get(self.id) {
|
||||
f(&mut scope.borrow_mut());
|
||||
scope.borrow_mut().push(prop);
|
||||
} else {
|
||||
console_warn(
|
||||
"tried to add property to a scope that has been disposed",
|
||||
|
|
|
@ -340,7 +340,7 @@ pub fn create_signal<T>(
|
|||
value: T,
|
||||
) -> (ReadSignal<T>, WriteSignal<T>) {
|
||||
let s = cx.runtime.create_signal(value);
|
||||
cx.with_scope_property(|prop| prop.push(ScopeProperty::Signal(s.0.id)));
|
||||
cx.push_scope_property(ScopeProperty::Signal(s.0.id));
|
||||
s
|
||||
}
|
||||
|
||||
|
@ -1107,7 +1107,7 @@ impl<T> Copy for WriteSignal<T> {}
|
|||
#[track_caller]
|
||||
pub fn create_rw_signal<T>(cx: Scope, value: T) -> RwSignal<T> {
|
||||
let s = cx.runtime.create_rw_signal(value);
|
||||
cx.with_scope_property(|prop| prop.push(ScopeProperty::Signal(s.id)));
|
||||
cx.push_scope_property(ScopeProperty::Signal(s.id));
|
||||
s
|
||||
}
|
||||
|
||||
|
|
|
@ -418,7 +418,7 @@ where
|
|||
.insert(Rc::new(RefCell::new(value)))
|
||||
})
|
||||
.unwrap_or_default();
|
||||
cx.with_scope_property(|prop| prop.push(ScopeProperty::StoredValue(id)));
|
||||
cx.push_scope_property(ScopeProperty::StoredValue(id));
|
||||
StoredValue {
|
||||
runtime: cx.runtime,
|
||||
id,
|
||||
|
|
Loading…
Reference in a new issue