subscribe method

void subscribe(
  1. AutoRouteAware routeAware,
  2. RouteData route
)

Subscribe routeAware to be informed about changes to route.

Going forward, routeAware will be informed about qualifying changes to route, e.g. when route is covered by another route or when route is popped off the Navigator stack.

Implementation

void subscribe(AutoRouteAware routeAware, RouteData route) {
  final Set<AutoRouteAware> subscribers =
      _listeners.putIfAbsent(route.key, () => <AutoRouteAware>{});
  if (subscribers.add(routeAware)) {
    if (route.router is TabsRouter) {
      routeAware.didInitTabRoute(null);
    } else {
      routeAware.didPush();
    }
  }
}