@serenity-is/domwise / withLifecycleRoot
Function: withLifecycleRoot()
withLifecycleRoot<
T>(root,fn):T
Defined in: src/disposing-listener.ts:239
Runs fn with the lifecycle root temporarily set to root, restoring the
previous root afterwards even if fn throws.
Use this instead of calling currentLifecycleRoot directly so that a thrown error cannot leave a stale root in the global state.
Type Parameters
T
T
Return type of fn.
Parameters
root
Root to install for the duration of fn (null/undefined clears it).
Element | null | undefined
fn
() => T
Callback executed while the root is installed.
Returns
T
The value returned by fn.