Skip a route from being remembered in Sencha Touch 2 history navigation - sencha-touch-2

In my Sencha Touch 2 app, I use history navigation and routes.
User is on home page and clicks on "products" which is a restricted route (user needs to be auth first).
From the router, using a before-filter, I see the route which is being accessed (in this case products) is protected, and I redirect the user to login view, using:
that.redirectTo('login');
This works like a charm.
But if the user, which is on the login view, hits the back button, Sencha remembered that the user wanted to visit the "products" route.
So Sencha tries to load the products view, reaches the router, the router see's the view is protected and redirects to login.
So in this way, the user will be stuck on the login page, no matter how many times he pushes the back button.
Now, the question:
When redirecting to a route, is there a way not to save that redirect into Sencha Touch's history?
Any idea?

For views that you don't want to have history support, simply add / change the view without using redirectTo.
Straigh to viewport:
Ext.Viewport.add({xtype: 'myview'})
or with navigation view (in a controller):
this.getMyNavView().push({xtype: 'myview'})

Related

Flutter share bloc between pages

I have a basic flutter app with 2 pages and 1 bloc.
The home page displays a list of users (only 2 attributes)
When a user-item is clicked, a detail page displays all attributes
The user data is fetched using a bloc which emits 2 states
AllUsersLoadedState from the api domain.com/users
UserLoadedState from the api domain.com/users/id
Because both home page and detail page is using the same bloc in their BlocBuilder when I navigate to the detail page and hit the back button, the home page is crashed.
Any way to handle it without writing 2 individual bloc?
If you want to share a BLoC between screens, then you should create the BLoC in such a way that it won't be destroyed while those 2 screens are active.
One way of doing this is to provide the BLoC using the Provider package, or as an InheritedWidget. If you use Provider then on each screen you just ask for the BLoC using Provider.of<MyBloc>(context). You will have to read more about Provider to learn how to use it.
Another way is passing the BLoC as a variable to your widget's constructor.
I figured out what was the issue.
Because both pages were using the same bloc they would rebuild on both states while the intended behavior was for the home page to rebuild only on AllUsersLoadedState and detail page to rebuild only on UserLoadedState.
So when I navigate to the detail page and a UserLoadedState is received the home page didn't know how to handle the state and would crash.
The solution is to use the condition parameter in the bloc builder to skip rebuilding on an unwanted state.

How to keep a view on the screen last visited by the user in react-native?

Suppose I have three screens in my application.
Screen A, Screen B, Screen C
Now If the user exists or if the app crashes when the user is on Screen B, I want to redirect the user directly to Screen B when the user visits the application again.
I am using react-navigation for navigating between screens.
Should I store the every Screen name visited by the user in async storage and then read that value on app launch and redirect user according to that value or is there any simple and easy way?
First and foremost thing , like i've done it in my app , but there are few catches with it. If you want to redirect to that screen if the app crashes , then it's possible by the way you suggest , that keep the name of page in async storage and then redirect upon app start.
Things to keep in mind.
1. The page which you are redirecting to should not have props dependencies from any page prior to that.
2. If the app starts, then navigation stack is cleared. So in android if user clicks on back button and if you have used this.props.navigation.goBack() it may misbehave, so keep that in mind. A fix to this would be on back button press you can do this.props.navigation.navigate('Screen').
Ive did this in login , like im storing token ,and if user opens next time it doesnt show login page , but home page. so you can do it too. Just take care of above points.

Refreshing Navigation In VUEJS

Assume that Home, Login and Register links in my navigation. After login, I want to hide or remove Login and Registration Links and instead want to display Logout and Dashboard Menu.
It works when I refresh the page. What is the best way to do that programmatically?
With this code you can refresh page with JavaScript:
// like an HTTP redirect
window.location.replace("/");
// like clicking on a link
window.location.href = "/";
This will redirect to your home page. If you want you can replace / with any address you want.
You can use vue-router to specify components in each view or you can use v-if or v-show directives to programmatically change flags of code blocks.

Aurelia Route History

How does one tell the router to ignore history for a particular view, for example when moving from a login view to the landing page, I want the login view not to appear in the navigation history (user must not be able to press the back button to the login view)
Similarly, if a user hits a page, and is redirected to the login view because the page requires authentication (this is currently done via pipeline step), the history should be maintained less the loginView.
Ok - found a potential solution using:
router.navigateToRoute(route, params, {trigger: true, replace: true}
when navigating to the new page after the LoginView.
The key is the replace: true parameter - which replaces the previous view in the history.

How can I have 'guardRoute' run before 'mapUnknownRoutes' in Durandaljs Router?

I'm using the Router in Durandaljs to control routing in a SPA. In my application all routes are created dynamically. Therefore I use only mapUnknownRoutes for mapping all routes. The problem I have is that if the user navigates between different hashes in the same page, clicking on 'back' leads to unloading the current page - something I wish to prevent. I thought of doing this by using guardRoute and there return 'false' when navigation remains in the same page, but 'guardRoute' runs only after 'mapUnknownRoutes' hence does not prevent the unloading of the current page.
Any suggestions?
Thanks !
Elior