injectAutoEffect
injectAutoEffect
is a CIF that returns an auto-wired Effect
, hence the name auto-effect
. This Effect
can be used in places that do not have an implicit Injection Context like ngOnInit
or afterNextRender
Usage
Clean up function
Normal effect()
can optionally invoke onCleanup
argument to run some clean-up logic every time the Effect
invokes.
injectAutoEffect()
allows the consumers to return a CleanUpFn
instead. This is purely preference and has no affect
on performance of effect()
Nested Effect
For normal effect
, we always need to pass in the Injector
to the 2nd parameter of nested effect()
.
For injectAutoEffect()
, autoEffect
will always be invoked with the initial Injector
(where we invoke injectAutoEffect()
).
Optionally, autoEffect
callback exposes the Injector
so consumers can make use of that if needed