Requiring users to remove listeners in onDestroy is sub-optimal now that lifecycle-aware observer is a thing.
There are two approaches:
- Use lifecycle observer and remove the listener upon
onDestroy
- Pros
- Less internal state is android-aware
- Cons
- Basically duplicating
LiveData's functionality
- Expose e.g. session state as
LiveData<SessionState>
- Pros
- Cons
- The internal state is lifecycle aware by default. Or, we can make authgear core listen to itself and dispatch
stateLiveData.value = state in onSessionStateChanged to make it fully modular
Must:
- Existing listener-based API must remain so that android apps which have not yet adopted lifecycle can still use the SDK
Requiring users to remove listeners in
onDestroyis sub-optimal now that lifecycle-aware observer is a thing.There are two approaches:
onDestroyLiveData's functionalityLiveData<SessionState>stateLiveData.value = stateinonSessionStateChangedto make it fully modularMust: