Queue an effect to run after the next render
(&self, id: ScopeId, f: impl FnOnce() + 'static)
| 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( |
no test coverage detected