Remove an extra CopyValue::invalid from maybe_sync_memo

This commit is contained in:
Evan Almloff committed 2024-01-24 14:33:39 -06:00
1 parent 1eb989a544
commit 30ef29d195
1 file changed
+1 -9
+1 -9
View File
@@ -261,9 +261,6 @@ impl<T: PartialEq + 'static> Signal<T> {
pub fn maybe_sync_memo<S: Storage<SignalData<T>>>( pub fn maybe_sync_memo<S: Storage<SignalData<T>>>(
mut f: impl FnMut() -> T + 'static, mut f: impl FnMut() -> T + 'static,
) -> ReadOnlySignal<T, S> { ) -> ReadOnlySignal<T, S> {
let mut state = Signal::<T, S> {
inner: CopyValue::invalid(),
};
let effect = Effect { let effect = Effect {
source: current_scope_id().expect("in a virtual dom"), source: current_scope_id().expect("in a virtual dom"),
inner: CopyValue::invalid(), inner: CopyValue::invalid(),
@@ -272,12 +269,7 @@ impl<T: PartialEq + 'static> Signal<T> {
{ {
EFFECT_STACK.with(|stack| stack.effects.write().push(effect)); EFFECT_STACK.with(|stack| stack.effects.write().push(effect));
} }
state.inner.value.set(SignalData { let mut state: Signal<T, S> = Signal::new_maybe_sync(f());
subscribers: Default::default(),
update_any: schedule_update_any(),
value: f(),
effect_ref: get_effect_ref(),
});
{ {
EFFECT_STACK.with(|stack| stack.effects.write().pop()); EFFECT_STACK.with(|stack| stack.effects.write().pop());
} }