flexxui / flexx

Write desktop and web apps in pure Python
http://flexx.readthedocs.io
BSD 2-Clause "Simplified" License
3.25k stars 258 forks source link

Routing and linking subsystem #189

Open Korijn opened 8 years ago

Korijn commented 8 years ago

Something that Flexx currently lacks in comparison to other UI toolkits is linking and routing.

An app with pages, links and URLs is typically implemented with a Router for single page applications. This usually also syncs with browser history to ensure the Back button functions, and so that users can share links. An example of this is react-router:(https://github.com/reactjs/react-router/blob/master/README.md).

What work do you think would be required for such a subsystem?

almarklein commented 8 years ago

I can imagine an app where you host multiple apps and have links between them. Would that give you what you mean? Maybe Flexx needs a way to write something like that (or the links) down more effectively?

Korijn commented 8 years ago

Well, as mentioned earlier, I think this is closely related to #182. Switching out whole hierarchies of subwidgets would be the main purpose of a Router widget. Triggering this can be done programmatically, and a Link widget would be designed ready-to-go.

Side-effects of the Router would include URL and history tracking.

IMHO, linking between multiple apps seems unrelated and more like something you can accomplish by implementing e.g. #178.

almarklein commented 8 years ago

Summarising in my own words: this feature would be a per-app ability to map the remainder of the url (after the app name) to the "configuration" of the app itself. E.g. http://foo.com/users would show a list of users, and http://foo.com/users/23 would show user 23.

Korijn commented 8 years ago

A nice example can be found here: https://github.com/reactjs/react-router/blob/master/examples/active-links/app.js