Coder Social home page Coder Social logo

Comments (6)

troch avatar troch commented on May 3, 2024

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.

JonathanWolfe avatar JonathanWolfe commented on May 3, 2024
  • 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.

troch avatar troch commented on May 3, 2024

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.

troch avatar troch commented on May 3, 2024

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.

JonathanWolfe avatar JonathanWolfe commented on May 3, 2024

Cool. I've got a light load at work so I'll look into it.

from router5.

troch avatar troch commented on May 3, 2024

Router5 v1.0.0 released. Closing this issue for now.

from router5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.