zilch / type-route

The flexible, type safe routing library.
https://type-route.zilch.dev
MIT License
424 stars 15 forks source link

Better understanding of internals and what changes between events. #110

Open seivan opened 2 years ago

seivan commented 2 years ago

I as hoping to get a better understanding of what actually goes on when e.g a new route is transitioned to when clicking or doing it programmatically.

More specifically, I was wondering what do we actually get back in the session listener.

For instance, when this is triggered

session.listen((route) => {

    // is Route a new object, or a mutated one? 
   // What is the absolute way to check for equality from previously stored route
  })
  1. Are we making the assumption that it's a whole new object?
  2. Thus it would fail a reference check with previously stored, even though the values are the same?
  3. Can you take it at face value that route.href is the object serialized and can be used for string checks for equality instead?
  4. When would the listener trigger and when wouldn't it?
  5. Would the same plain route trigger it twice?
  6. Would the same route but with different query params, trigger it?
  7. What about exact same query and params but state?