csells / go_router

The purpose of the go_router for Flutter is to use declarative routes to reduce complexity, regardless of the platform you're targeting (mobile, web, desktop), handling deep linking from Android, iOS and the web while still allowing an easy-to-use developer experience.
https://gorouter.dev
441 stars 96 forks source link

[Proposal] Support multiple `refreshListenable`s #176

Closed benPesso closed 2 years ago

benPesso commented 2 years ago

Pretty self explanatory, but it would make life easier.

Instead of having to do this:

refreshListenable: ref.read(routerRefreshProvider.notifier)

We could do this (and maybe rename the property along the way to refreshNotifiers, since that's what it does):

refreshNotifiers: [ref.read(authStatusProvider.notifier), ref.read(incomingAlertProvider.notifier), ...]
csells commented 2 years ago

I think it's pretty easy to create an aggregator that turns multiple listenables into a single listenable.

benPesso commented 2 years ago

It is, but it's not verbose enough, and it adds another degree of separation in the code. Creating an aggregator (as in my first example) is just needless overhead, in my opinion.

letsar commented 2 years ago

Hi @benPesso, you can use Listenable.merge for that I think.

csells commented 2 years ago

Pro tip! https://api.flutter.dev/flutter/foundation/Listenable/Listenable.merge.html