slovnicki / beamer

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

How to know what was the last action inside BeamLocation buildPages callback #600

Closed mladjomilunovic closed 1 year ago

mladjomilunovic commented 1 year ago

First thanks for a great package!

It would really help to have a way to know which action happened when creating pages in a BeamLocation. So for example if the action was beamToNamed, beamToReplacementNamed, or Navigator.pop(), essentialy the last action that led to the current route. Is there a way currently to have this information, if not does anybody have a suggestion?

Thank you.

r-ilagan commented 1 year ago

You should take a look into NavigatorObserver. You can pass a list of them to BeamerDelegate if you want to be aware of Navigator changes. There is also RouteAware mixin that you can use for your screens. Hope this helps!

mladjomilunovic commented 1 year ago

@r-ilagan Hi, thank you for the suggestion. I tried, for pop actions it works fine. But other actions such as push get observed after the buildPages callback(so I can't know which action was requested). :/

mladjomilunovic commented 1 year ago

In the end what I did was extend the BeamerDelegate and just save the action on each callback, and that seems to work.