MCPcopy Create free account
hub / github.com/DioxusLabs/dioxus / queue_effect

Method queue_effect

packages/core/src/tasks.rs:214–228  ·  view source on GitHub ↗

Queue an effect to run after the next render

(&self, id: ScopeId, f: impl FnOnce() + 'static)

Source from the content-addressed store, hash-verified

212
213 /// Queue an effect to run after the next render
214 pub(crate) fn queue_effect(&self, id: ScopeId, f: impl FnOnce() + 'static) {
215 let effect = Box::new(f) as Box<dyn FnOnce() + 'static>;
216 let Some(scope) = self.try_get_state(id) else {
217 return;
218 };
219 let mut status = scope.status.borrow_mut();
220 match &mut *status {
221 ScopeStatus::Mounted => {
222 self.queue_effect_on_mounted_scope(id, effect);
223 }
224 ScopeStatus::Unmounted { effects_queued, .. } => {
225 effects_queued.push(effect);
226 }
227 }
228 }
229
230 /// Queue an effect to run after the next render without checking if the scope is mounted
231 pub(crate) fn queue_effect_on_mounted_scope(

Callers 1

queue_effectFunction · 0.45

Calls 3

try_get_stateMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected