Skip to content

Commit

Permalink
Merge pull request #170 from nhaarman/fix-notify-order
Browse files Browse the repository at this point in the history
Invoke Scene.onStart after listener notification for StackNavigator
  • Loading branch information
nhaarman authored Sep 11, 2020
2 parents c2c0f88 + 8dc420f commit 37f638b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,9 @@ abstract class StackNavigator(

override fun start(): StateTransition {
return StateTransition(Active(scenes, listeners)) {
scenes.last().onStart()
// These lines should be swapped
listeners.forEach { it.scene(scenes.last(), null) }
scenes.last().onStart()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,21 @@ internal class StackNavigatorTest {
verify(scene1).onStart()
}
}

@Test
fun `starting the navigator invokes listeners before starting the scene`() {
/* Given */
navigator.addNavigatorEventsListener(listener)

/* When */
navigator.onStart()

/* Then */
inOrder(listener, scene1) {
verify(listener).scene(eq(scene1), anyOrNull())
verify(scene1).onStart()
}
}
}

class TestStackNavigator(
Expand Down

0 comments on commit 37f638b

Please sign in to comment.