Firebaseui-android: Use Android Architecture Components

Created on 21 May 2017  路  9Comments  路  Source: firebase/FirebaseUI-Android

Google I/O unveiled a new set of Android Architecture Components, and it seems some components, like LiveData and ViewModel, fit almost perfectly to the functions performed by the library. Are there any plans to use these components when they' are stable and are compatible with the support libraries?

fix-implemented feature request

Most helpful comment

@TheCraftKid @b95505017

Hello everyone,
I've finally gotten around refactoring my app to use Arch Components and it's amazing! However, now that I'm more familiar with the AC api, I've realized that LiveData doesn't work well with the Firebase model of multi-state updates.

So LiveData is out of the picture, but what we _can_ do is auto subscribe and unsubscribe from events for you!!! This is truly what makes AC amazing! Like what Yigit said on ADB, AC will enables libraries to remove those annoying startListening and cleanup callbacks. This is what I've done in #827.

All 9 comments

@TheCraftKid Yeah, I definitely think that would be awesome to support!!! At the moment I've been reeling from all the announcement and updates at I/O so I've been overwhelmed with trying to learn Kotin and updating my app with all the new stuff. Once I have the time, I'd love to take a look at that and how we could implement it. 馃槃 For now though I think I have enough open PRs 馃槅

@SUPERCILEX I'd be happy to submit a PR while the rest of FirebaseUI is being sorted out and when the Android Architecture Components are stable.

@TheCraftKid Go for it! 馃槃 (Just make sure to base your PR off the version-2.0.0-dev branch)

Okay, I got a bit excited, and while the components will change before release, I think I can begin the process of implementing LiveData.
The first decision to make when implementing this is composition vs inheritance. In the 2.0.0 branch, FirebaseArray extends CachingObservableSnapshotArray which extends ObservableSnapshotArray which extends ImmutableList. Making ImmutableList extend LiveData doesn't make sense, so I'm thinking we make ObservableSnapshotArray implement List and have it extend LiveData instead.

What are your thoughts, @SUPERCILEX?

@TheCraftKid Nope. 馃槅 You're getting there though! 馃榾 You're right about the composition part, but extending ImmutableList is a hard requirement so we can't change that. Instead of updating the existing classes, let's make a new class that extends LiveData and takes in an ObservableSnapshotArray in the constructor. Then, you can add a listener to the snapshot array and notify the livedata of changes whenever they come in.

I'm curious about how LiveData notify the partial data updated (onChildChanged).
In google sample, I see they use DiffUtil stuff to calculate the partial data, which is unnecessary for library like Firebase has onChildChanged API already.

@TheCraftKid @b95505017

Hello everyone,
I've finally gotten around refactoring my app to use Arch Components and it's amazing! However, now that I'm more familiar with the AC api, I've realized that LiveData doesn't work well with the Firebase model of multi-state updates.

So LiveData is out of the picture, but what we _can_ do is auto subscribe and unsubscribe from events for you!!! This is truly what makes AC amazing! Like what Yigit said on ADB, AC will enables libraries to remove those annoying startListening and cleanup callbacks. This is what I've done in #827.

Marking this as fix-implemented due to @SUPERCILEX's change and investigation.

The fix for this issue was released in version 2.2.0.

Was this page helpful?
0 / 5 - 0 ratings