val userList = ObservableArrayList<User> … fun addOnListChangedCallback(callback: ObservableList.OnListChangedCallback<ObservableList<User>>) { userList.addOnListChangedCallback(callback) } fun removeOnListChangedCallback(callback: ObservableList.OnListChangedCallback<ObservableList<User>>) { userList.removeOnListChangedCallback(callback) } Store
val listSubject = PublishSubject.create<List<User>>() val listState: Observable<List<User>> = listSubject.hide() init { Streaming Loading State Change Using RxJava Store
val listSubject = PublishSubject.create<List<User>>() val listState: Observable<List<User>> = listSubject.hide() init { Streaming UserList Change Using Data Binding Store
activityKey) { when (action) { is LoadingAction.Loading -> { loadingSubject.onNext(true) } is LoadingAction.Idle -> { loadingSubject.onNext(false) } … Store When given action is Loading, then the next loading state is “true”, if the action is Idle, then “false”.
{ is UserAction.Favorite -> { userList.find { it.id == action.targetUserId }?.let { // Update or replace with new user } } } … When given action is User’s Favorite Action, then find target user from user list and update as favorited (if there is).