signals: Rebuild stale global cache entries automatically (#4809)
* signals: Rebuild stale global cache entries automatically * remove log --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
07b9dcb3a7
commit
8b427ddf16
1 file changed
+9
-1
@@ -182,12 +182,20 @@ where
|
||||
let context = get_global_context();
|
||||
|
||||
// Get the entry if it already exists
|
||||
let mut evicted_stale_entry = false;
|
||||
{
|
||||
let read = context.map.borrow();
|
||||
if let Some(signal) = read.get(&key) {
|
||||
return signal.downcast_ref::<T>().cloned().unwrap();
|
||||
if let Some(signal) = signal.downcast_ref::<T>() {
|
||||
return signal.clone();
|
||||
}
|
||||
evicted_stale_entry = true;
|
||||
}
|
||||
}
|
||||
|
||||
if evicted_stale_entry {
|
||||
context.map.borrow_mut().remove(&key);
|
||||
}
|
||||
// Otherwise, create it
|
||||
// Constructors are always run in the root scope
|
||||
let signal = dioxus_core::Runtime::current().in_scope(ScopeId::ROOT, || {
|
||||
|
||||
Reference in new issue
Block a user