Skip to content

Commit

Permalink
Do not terminate default lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
zhxnlai committed Jan 17, 2019
1 parent 7e3ab5d commit abf165a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class EchoBotFragment : Fragment() {
val numberOfMessages = chatView.getMessageView().messageList.size
if (numberOfMessages == 0) {
setMessages(chatMessages)
} else if (chatMessages.isEmpty()) {
chatView.getMessageView().removeAll()
} else {
for (i in numberOfMessages until chatMessages.size) {
addMessage(chatMessages[i])
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,6 @@ internal class GsonMessageAdapterTest {
@Receive
fun observeEvents(): Stream<WebSocketEvent>

@Receive
fun observeStateTransition(): Stream<StateTransition>

@Send
fun sendString(message: String): Boolean

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ package com.tinder.scarlet.lifecycle

import com.tinder.scarlet.Lifecycle
import com.tinder.scarlet.LifecycleState
import io.reactivex.Flowable

internal class DefaultLifecycle() : Lifecycle by FlowableLifecycle(
Flowable.just(LifecycleState.Started)
)
internal class DefaultLifecycle(
private val lifecycleRegistry: LifecycleRegistry = LifecycleRegistry()
) : Lifecycle by lifecycleRegistry {
init {
lifecycleRegistry.onNext(LifecycleState.Started)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ internal class DefaultLifecycleTest {
// Then
testSubscriber.assertValues(LifecycleState.Started)
}

@Test
fun observeState_shouldNotTerminate() {
// When
val testSubscriber = Flowable.fromPublisher(defaultLifecycle).test()

// Then
testSubscriber.assertNotTerminated()
}

}

0 comments on commit abf165a

Please sign in to comment.