Skip to content

Commit

Permalink
Detach children before self
Browse files Browse the repository at this point in the history
  • Loading branch information
davissuber committed Aug 25, 2023
1 parent 85cf3b3 commit 9bc16f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ protected constructor(
public open fun dispatchDetach() {
checkForMainThread()

interactorGeneric.dispatchDetach()
willDetach()
for (child in children) {
detachChild(child)
}
interactorGeneric.dispatchDetach()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,23 @@ class InteractorAndRouterTest {
router.dispatchDetach()

// Then.
val ribActionInfoValues = ribActionInfoObserver.values()
ribActionInfoValues
.last()
.assertRibActionInfo(
RibEventType.DETACHED,
RibActionEmitterType.ROUTER,
RibActionState.COMPLETED,
"com.uber.rib.core.FakeRouter",
)
verify(childInteractor).dispatchDetach()
val ribActionInfoValues = ribActionInfoObserver.values()
val childRouterDetachIndex =
ribActionInfoValues.indexOfFirst {
it.ribEventType == RibEventType.DETACHED &&
it.ribActionEmitterType == RibActionEmitterType.ROUTER &&
it.ribActionState == RibActionState.COMPLETED
}
val selfInteractorDetachIndex =
ribActionInfoValues.indexOfFirst {
it.ribEventType == RibEventType.DETACHED &&
it.ribActionEmitterType == RibActionEmitterType.INTERACTOR &&
it.ribActionState == RibActionState.COMPLETED
}
assertThat(selfInteractorDetachIndex).isGreaterThan(-1)
assertThat(childRouterDetachIndex).isGreaterThan(-1)
assertThat(selfInteractorDetachIndex > childRouterDetachIndex).isTrue()
}

@Test
Expand Down

0 comments on commit 9bc16f2

Please sign in to comment.