listener.onMsg(msg), where msg.state is the state value.
This API depends on the internal event channel registered by
init(). Call PluginManager.init() first, then register the lifecycle listener.
Returns
PluginEventSubscription: subscription object. Callremove()to unregister the listener
- The callback receives the event
data, not the full original message. Usemsg.stateto determine the current lifecycle state - If the listener is registered after the event arrives, and the most recent lifecycle event is still within 1 second, that last event is delivered immediately so the listener does not miss it