Skip to content
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

Feature query: stateful routes (module + viewport) #534

Open
jwx opened this issue Oct 14, 2017 · 10 comments · May be fixed by #538
Open

Feature query: stateful routes (module + viewport) #534

jwx opened this issue Oct 14, 2017 · 10 comments · May be fixed by #538
Assignees

Comments

@jwx
Copy link
Member

jwx commented Oct 14, 2017

I've got code for stateful routes, meaning that if you do this

{ route: 'dashboard', name: 'dashboard', viewPorts: { 'default': { moduleId: 'dashboard', stateful: true } } }

the same instance of the dashboard module will be presented in the default viewport everytime a stateful route specifies it after the initial time. The view/viewmodel will remain loaded even when navigating away to another route, meaning that state such as list sorting, entered values, positions on google maps etc will be the same when coming back to it. It also means that the viewmodel will be able to listen to and act upon events from the event manager, signals and so on.

So to clarify, this is not caching for views/viewmodels, it's stateful views/viewmodels that are never unloaded.

If this is of interest to anyone else and has any chance of being accepted into the router I could put together a PR.

@jwx
Copy link
Member Author

jwx commented Oct 14, 2017

Is this something you want in? @EisenbergEffect @bryanrsmith

@TonyLugg
Copy link

I like it!

jwx added a commit to jwx/router that referenced this issue Oct 17, 2017
Adds stateful routes so that route configurations can specify a module or a module in a viewport as `stateful: true`. A stateful module that's loaded in a viewport is never unloaded when navigating away, it's just not shown, and is displayed with the same state whenever a route places it in the same viewport again.

Depending on aurelia/templating-router#64 and aurelia#536.
Closes aurelia#534.
@jwx jwx linked a pull request Oct 17, 2017 that will close this issue
jwx added a commit to jwx/router that referenced this issue Oct 19, 2017
Adds stateful routes so that route configurations can specify a module or a module in a viewport as `stateful: true`. A stateful module that's loaded in a viewport is never unloaded when navigating away, it's just not shown, and is displayed with the same state whenever a route places it in the same viewport again.

Depending on aurelia/templating-router#64 and aurelia#536.
Closes aurelia#534.
jwx added a commit to jwx/templating that referenced this issue Oct 19, 2017
Adds stateful routes so that route configurations can specify a module or a module in a viewport as stateful: true. A stateful module that's loaded in a viewport is never unloaded when navigating away, it's just not shown, and is displayed with the same state whenever a route places it in the same viewport again.

Required by aurelia/router/stateful-viewports.
Closes aurelia/router#534.
jwx added a commit to jwx/templating-router that referenced this issue Oct 20, 2017
Adds stateful routes so that route configurations can specify a module or a module in a viewport as `stateful: true`. A stateful module that's loaded in a viewport is never unloaded when navigating away, it's just not shown, and is displayed with the same state whenever a route places it in the same viewport again.

Required by aurelia/router#538.
Closes aurelia/router#534.
@davismj
Copy link
Member

davismj commented Nov 12, 2017

@jwx Isn't this solved by making your view model a app singleton?

https://gist.run/?id=f9ec79977fdc755e65fd8bc69aa5fb44

@davismj
Copy link
Member

davismj commented Dec 10, 2017

@EisenbergEffect see here

@jwx
Copy link
Member Author

jwx commented Dec 10, 2017

@davismj @EisenbergEffect Making the view model a singleton only preserves the view model state. State details not bound to the view model is lost, for example an unbound scroll position in a list or unbound position and zooming in a google map. Basically, this is completely cached views through show and hide.

@davismj
Copy link
Member

davismj commented Dec 11, 2017

Good info. I'll review again.

I'd like to pull this in out of the context of the optional and default view ports. This seems like a totally separate item.

@davismj davismj self-assigned this Dec 11, 2017
@bigopon
Copy link
Member

bigopon commented Dec 11, 2017

I'd like to add in that making something singleton is not always viable. Sometime the element used at the leaf - route may end up being a real element in another context, thus making them singleton will not allow this scenario. My use case is I have a complex editor as a route, but then in another route, I reuse the element in a dialog.

@Alexander-Taran
Copy link
Contributor

Don't like the seeming hackiness of it. Kinda shoehorning.
you actually can achieve it with optional viewports now i think and a bit of css magic.

@jwx
Copy link
Member Author

jwx commented Mar 22, 2018

@Alexander-Taran See #538.

jwx added a commit to jwx/router that referenced this issue Sep 19, 2018
Adds stateful routes so that route configurations can specify a module or a module in a viewport as `stateful: true`. A stateful module that's loaded in a viewport is never unloaded when navigating away, it's just not shown, and is displayed with the same state whenever a route places it in the same viewport again.

Depending on aurelia/templating-router#64 and aurelia#536.
Closes aurelia#534.
jwx added a commit to jwx/templating that referenced this issue Sep 19, 2018
Adds stateful routes so that route configurations can specify a module or a module in a viewport as stateful: true. A stateful module that's loaded in a viewport is never unloaded when navigating away, it's just not shown, and is displayed with the same state whenever a route places it in the same viewport again.

Required by aurelia/router/stateful-viewports.
Closes aurelia/router#534.
jwx added a commit to jwx/templating-router that referenced this issue Sep 19, 2018
Adds stateful routes so that route configurations can specify a module or a module in a viewport as `stateful: true`. A stateful module that's loaded in a viewport is never unloaded when navigating away, it's just not shown, and is displayed with the same state whenever a route places it in the same viewport again.

Required by aurelia/router#538.
Closes aurelia/router#534.
@jfstephe
Copy link

@bigopon @jwx - any news on this or #538 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants