cbcrc / koco-router

Simple Knockout router
MIT License
2 stars 1 forks source link

Add support for cached routes #5

Open RCMax opened 9 years ago

RCMax commented 9 years ago

A cached route (new setting on the route) would be cached by the router when a user navigates away so it can be "re-rendered" when the user comes back to the same URL.

Flow
  1. the user goes to route "home"
  2. (optional) the user do some actions that impact the page (ex. paging a list)
  3. the user navigates to another page
  4. if the page is a different route (pattern) and the route is configured to be cached then the DOM inside the router tag is stored in the router state... the router prints the new page...
  5. the user clicks the back button (or navigate back to the home page)
  6. the router checks if the route is cached (the URL most be the exact same) and prints it from the cache if it is... else the router does its thing...
    Notes
    • for listing pages - this means that you need to add a way to refresh the list
W3Max commented 9 years ago

This will have to take account of sub-routers if we decide to implement it.

RCMax commented 9 years ago

This will have to take the snapshot of the page when the user leaves it and not when we arrive on a new page since the page may not be rendered and what we what we want is the state of the page at the last moment (think after paging a list).

RCMax commented 9 years ago

On going...

on peut maintenant cacher le viewmodel pour une route. addRoute(bla bla bla, {cached:true}). Ceci dit, je ne crois pas que c'est très utilie pour l'instant. Il reste selon moi à

RCMax commented 9 years ago

Ne pas oublier de valider qu'on a pas de problèmes dûent aux dispose!!!