Skip to content

Commit

Permalink
refactored away from if/else
Browse files Browse the repository at this point in the history
  • Loading branch information
jquesada2016 committed Sep 20, 2023
1 parent 6ba8315 commit 168b833
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions leptos_reactive/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ pub fn try_with_owner<T>(owner: Owner, f: impl FnOnce() -> T) -> Option<T> {
.try_borrow()
.map(|nodes| nodes.contains_key(owner.0))
.map(|scope_exists| {
if scope_exists {
scope_exists.then(|| {
let prev_observer = runtime.observer.take();
let prev_owner = runtime.owner.take();

Expand All @@ -878,10 +878,8 @@ pub fn try_with_owner<T>(owner: Owner, f: impl FnOnce() -> T) -> Option<T> {
runtime.observer.set(prev_observer);
runtime.owner.set(prev_owner);

Some(v)
} else {
None
}
v
})
})
.ok()
.flatten()
Expand Down

0 comments on commit 168b833

Please sign in to comment.