Lifecycle
Esta página aún no está disponible en tu idioma.
In Reactter, both the states and the dependency (managed by the dependency injection) contain different stages,
also known as Lifecycle
.
The lifecycle entails events emitted through the event handler.
Let’s explore the lifecycle events:
Lifecycle.registered
: is triggered when the dependency has been registered.Lifecycle.created
: is triggered when the dependency instance has been created.Lifecycle.willMount
(exclusive of flutter_reactter package): is triggered when the dependency is going to be mounted in the widget tree.Lifecycle.didMount
(exclusive of flutter_reactter package): is triggered after the dependency has been successfully mounted in the widget tree.Lifecycle.willUpdate
: is triggered anytime the state or the dependency is about to be updated. The event parameter is aRtState
.Lifecycle.didUpdate
: is triggered anytime the state or the dependency has been updated. The event parameter is aRtState
.Lifecycle.willUnmount
(exclusive of flutter_reactter package): is triggered when the dependency is about to be unmounted from the widget tree.Lifecycle.didUnmount
(exclusive of flutter_reactter package): is triggered when the dependency has been successfully unmounted from the widget tree.Lifecycle.deleted
: is triggered when the dependency instance has been deleted.Lifecycle.unregistered
: is triggered when the dependency is no longer registered.
Using Event Handler
You can listen to the lifecycle events of a dependency using Rt.on
or Rt.one
method of the event handler. e.g:
Using LifecycleObserver
Extend your instances with LifecycleObserver
and use its methods to observe the lifecycle events. e.g:
Using UseEffect
The UseEffect
hook can be used to listen to the lifecycle events of a dependency. e.g: