Skip to content

Commit

Permalink
Connect to source explicitly.
Browse files Browse the repository at this point in the history
  • Loading branch information
pardom committed Aug 26, 2016
1 parent a4a99dd commit 1d65c9e
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ class ItemDetailView : RelativeLayout {
.subscribe { model.dispatch(Action.Share()) }
.addTo(subscriptions)

val modelChanges = model.asObservable().share()
val modelChanges = model.asObservable()
.startWith(model.getState())
.publish()

modelChanges
.startWith(model.getState())
.map { it.item.title }
.filter { it != null }
.cast(String::class.java)
Expand All @@ -76,18 +77,20 @@ class ItemDetailView : RelativeLayout {
.addTo(subscriptions)

modelChanges
.startWith(model.getState())
.map { it.children }
.distinctUntilChanged()
.subscribe { adapter.setItems(it) }
.addTo(subscriptions)

modelChanges
.startWith(model.getState())
.map { it.loading }
.distinctUntilChanged()
.subscribe { adapter.setLoading(it) }
.addTo(subscriptions)

modelChanges
.connect()
.addTo(subscriptions)
}

override fun onDetachedFromWindow() {
Expand Down

0 comments on commit 1d65c9e

Please sign in to comment.