Only experienceWillDisappear() was working properly.
experienceWillAppear() and experienceDidAppear() weren't being called because we were only checking isBeingPresented (which works for modals/tooltips) and not also isMovingToParent. I cleaned all the checks up with a simpler extension.
experienceDidDisappear() wasn't working because the state machine reaches the .idling state before containerDidDisappear gets called. This is essentially because the completion() for the dismisser of the embed gets called too early. There's nothing logically wrong with where it's called, but DispatchQueue.main.async fixes it. Alternatively, I could've added a case for .idling in containerDidDisappear but that could have wider ranging side effects an would be specific to embeds, which is the sort of code we've tried to avoid in the state machine.
Only
experienceWillDisappear()
was working properly.experienceWillAppear()
andexperienceDidAppear()
weren't being called because we were only checkingisBeingPresented
(which works for modals/tooltips) and not alsoisMovingToParent
. I cleaned all the checks up with a simpler extension.experienceDidDisappear()
wasn't working because the state machine reaches the.idling
state beforecontainerDidDisappear
gets called. This is essentially because thecompletion()
for the dismisser of the embed gets called too early. There's nothing logically wrong with where it's called, butDispatchQueue.main.async
fixes it. Alternatively, I could've added a case for.idling
incontainerDidDisappear
but that could have wider ranging side effects an would be specific to embeds, which is the sort of code we've tried to avoid in the state machine.