run<T> method
T
run<T>(
- T fn()
Runs fn with this scope as the active subscriber and ambient scope.
Returns the result of fn. Effects created inside fn are owned by this
scope unless they are detached.
Implementation
T run<T>(T Function() fn) {
final prevSub = setActiveSub(this);
final prevScope = setActiveScope(this);
try {
return fn();
} finally {
setActiveScope(prevScope);
setActiveSub(prevSub);
}
}