slovnicki / beamer

A routing package built on top of Router and Navigator's pages API, supporting arbitrary nested navigation, guards and more.
MIT License
589 stars 130 forks source link

More power to `BeamState`; types and notifiers #614

Open slovnicki opened 1 year ago

slovnicki commented 1 year ago

This is a work in progress proposal and will be updated with implementation details

For more details about where this is coming from, visit v2 Roadmap Discussion or v2 Roadmap Wiki.
This issue will be separated into multiple issues when implementation details become clearer;

Motivation

The goal of Router API was to have declarative routing which is guided by state instead of imperative calls. But, in practice, most developers want completely imperative routing and some scenarios require it. Beamer can be used in both ways, where simple imperative API (Beamer.beamTo*) is default, but we have the ability to create our own states whose change will guide the beaming. We will keep the current imperative high-level API, but will rework the internals slightly so the changes on BeamStates guide beaming directly, instead of BeamState being (by default) just a collection of current routing parameters. Another thing that would be nice to have is strong types on the routing parameter, such as being able to declare that the :id in route should be an integer.