wealthfront / magellan

The simplest navigation library for Android.
Apache License 2.0
677 stars 71 forks source link

Add callback to override navigation intents #230

Closed cmathew closed 2 years ago

cmathew commented 2 years ago

By returning true, NavigationRequestHandler#onNavigationRequested can block a navigation from happening. The idea is that onNavigationRequested can perform its own replacement navigation, show a dialog, whatever.

Key use-case is applying some global logic around when users should be asked to update their app.

ryanmoelter commented 2 years ago

Hmm, I have to take more of a look at this before having strong opinions, but this seems like a kind of fragile way to do this.

Could we instead make a VersionCheckerStep that wraps another Step/Journey, takes an enum like a VersionSensitiveFeature or something, and does the check there? That way, the check is happening at the local level rather than needing to be maintained at a global level, meaning it's easier to remember to update it when e.g. you change what journey/step is associated with a feature, and it's one less thing that we configure through Magellan.

Another option would be to wrap that sort of version-checking logic in a LifecycleAware component of some sort, basically the same effect through a slightly different mechanism.

The downside would be that we have to do this at each entry point to a feature, but for new features at least that should be a Journey (i.e. only one entry point), so that shouldn't be too bad once we migrate more.

Obv nothing I say is a blocker, but I'll look at this again over the weekend or early next week. (Going skiing tomorrow! 🏂️)