UseEffect constructor
UseEffect(
- Function callback,
- List<
ReactterHook> dependencies, [ - ReactterContext? context
Implementation
UseEffect(
this.callback,
this.dependencies, [
this.context,
]) : super(context) {
listenHooks(dependencies);
if (context == null) {
_watchDependencies();
return;
}
if (context is DispatchEffect) {
_runCallbackAndWatchDependencies(null, null);
}
Reactter.on(
context,
Lifecycle.didMount,
_runCallbackAndWatchDependencies,
);
Reactter.on(
context,
Lifecycle.willUnmount,
_runCleanupAndUnwatchDependencies,
);
Reactter.one(context, Lifecycle.destroyed, (_, __) => dispose());
}