Comments (6)
A few questions before trying to give an educated answer:
- What do you use for your view layer?
- What does
mountPage(...)
do? - Are your routes flat?
from router5.
- I'm using Riot.JS for my views.
mountPage
is just the method I wrote to unmount the current page and mount the next one.- No, my routes aren't completely flat
from router5.
The three types of listeners (addListener, addNodeListener, addRouteListener) were designed to be called by components. Because components will appear and disappear during the course of an application runtime, I think it would be confusing to be able to add them when configuring a router. This is especially true for node listeners which are designed to be used to update a view (the other ones are there to help with edge-cases and "side updates" of your view).
My idea is to try to keep router5 as lean as possible, and have it as a base to create more complex systems. My current thought process is to make listeners an optional middleware rather than integrating them further with routes, and have the router only taking care of updating a piece of state.
Another middleware which could be added is to have onActivate / onDeactivate functions (for data loading / unloading purposes). That might be more what you are trying to achieve with something like onNavigate
.
So far router5 supports the addition of a single middleware (you obviously compose functions to create a middleware). I am still thinking about what to do and where to go, but I am more looking at decoupling things.
from router5.
Hi @JonathanWolfe, I don't know where you are at with your use of router5 with riot.js. Version 1.0.0 of router5 will be published during the week, it introduces the concept of router plugins where you can trigger operations on start, stop, transition start, transition error, transition success... Each plugin receives the router instance which allows us to decorate it with some methods. This is what router5-listeners does. If you want a specific API to suit riot.js, then you'll then be able to implement it. Multiple middleware functions are also supported with [email protected]
from router5.
Cool. I've got a light load at work so I'll look into it.
from router5.
Router5 v1.0.0 released. Closing this issue for now.
from router5.
Related Issues (20)
- router5-plugin-browser base is case-sensitive
- TypeError of router5-transition-path HOT 2
- Unhandled promise rejection Error: Alias is already defined in route node in legacy Edge
- Integration(solid-js): reactivity of instance methods, getState vs subscribe's route, etc
- GitHub Pages and router5(+react) HOT 1
- Is non-latin letters are supported in the "path"?
- Remove the routes HOT 1
- Are arrays allowed as route params? HOT 1
- Improve type definitions
- Listeners plugin exposes incorrect typedefs HOT 1
- How to dynamically change base path on browserPlugin
- roadmap? HOT 2
- How can can pass query params to Link by react-router5? HOT 1
- Feature request on Navigation HOT 5
- BUG: errors handling unicode emoji
- QUESTION: Can I use the browser plugin but have each route specify when to use pushState vs replaceState? HOT 2
- Is this project abandoned? HOT 1
- There is an error in the areStatesEqual method
- Anyone interested to keep the package maintained? HOT 1
- cloneRouter() uses same root node
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from router5.