-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: refactor navcontroller tracking plugin teardown #70
Merged
vgupta98
merged 28 commits into
develop.poc
from
refactor/sdk-2674-refactor-navcontroller-tracking-plugin-teardown
Nov 28, 2024
Merged
refactor: refactor navcontroller tracking plugin teardown #70
vgupta98
merged 28 commits into
develop.poc
from
refactor/sdk-2674-refactor-navcontroller-tracking-plugin-teardown
Nov 28, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
the analyticsJob needs to be declared as a global private variable since it is used inside the secondary contructor
SDK-2674 [Android] Make NavControllerTrackingPlugin teardown call complete
Description Currently, the teardown of NavControllerTrackingPlugin only removes the stored navContexts. We also need to remove the attached NavControllerActivityObserver on teardown. Tech design / Research Acceptance Criteria
Checklist:
|
ChryssaAliferi
approved these changes
Nov 26, 2024
…ler-tracking-plugin-teardown
1abhishekpandey
approved these changes
Nov 28, 2024
Comment on lines
+89
to
+94
val observerToBeAdded = provideNavControllerActivityObserver( | ||
plugin = this, | ||
navContext = navContext | ||
) | ||
observerToBeAdded.addObserver() | ||
activityObservers.add(observerToBeAdded) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may consider using the scope function.
vgupta98
deleted the
refactor/sdk-2674-refactor-navcontroller-tracking-plugin-teardown
branch
November 28, 2024 08:17
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR refactors the
teardown
functionality forNavControllerTrackingPlugin
so that the activity observers are also removed when teardown happens.Type of change
Implementation Details
withContext(NonCancellable)
. It ensures that it is called even when the coroutine is cancelled during the time of shutdown. We need this when we remove all the contexts during teardown.NavControllerTrackingPlugin
.NavControllerActivityObserver
exposes methods to add and remove observers which are being used in the plugin to add and remove the observers andnavContextState
subscriber is called.teardown
is called,RemoveAllNavContextsAction
is dispatched, which basically removes all the navContexts fromnavContextState
. It then calls the subscriber which will clearcurrentNavContexts
andactivityObservers
and remove theOnDestinationChangedListener
and activity lifecycle observers.addObserver
andremoveObserver
calls inNavControllerActivityObserver
userunOnMainThread
to ensure that adding and removing of observers happen on main thread.Checklist
How to test?
Apply this patch and test the changes on fragment and compose sample apps.
Breaking Changes
Maintainers Checklist
Screenshots (if applicable)
Additional Context