Skip to content

//reactivestate/com.ensody.reactivestate.android/handleEvents

handleEvents

[android]\ fun <T : ErrorEvents> EventNotifier<T>.handleEvents(handler: T, owner: LifecycleOwner)

Consumes and handles EventNotifier’s events on the given handler, but only when owner is in >=STARTED state.

IMPORTANT: You have to call this function exactly once for the whole lifecycle of owner. Usually that means Activity.onCreate/Fragment.onViewCreated.

Any errors during event handling will trigger ErrorEvents.onError on the handler.

WARNING: Try to avoid switching threads within your handler’s methods! Otherwise your operation can get canceled and lost when rotating or locking the screen. Always stay on the main thread.