authgear / authgear/authgear-sdk-android

Add lifecycle observer support for all listeners

Open
#25 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Kotlin
Stars
3
Forks
15
Avg merge
4h 43m
Merged PRs (30d)
2

Description

Requiring users to remove listeners in `onDestroy` is sub-optimal now that lifecycle-aware observer is a thing.

There are two approaches:
1. Use lifecycle observer and remove the listener upon `onDestroy`
- Pros
- Less internal state is android-aware
- Cons
- Basically duplicating `LiveData`'s functionality
2. Expose e.g. session state as `LiveData`
- Pros
- Less work. Just works™
- 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

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the existing listener-based API and the two proposed approaches: lifecycle observers that remove listeners on onDestroy, or exposing session state through LiveData. Confirm that the existing listener API remains available for apps without lifecycle support, then define the supported behavior and validation for lifecycle-aware listeners.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
authentication, mobile
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.