11import 'dart:async' ;
22
33import 'package:grumpy/grumpy.dart' ;
4+ import 'package:meta/meta.dart' ;
45
56/// A service responsible for managing application routing.
67/// Note: This router is only responsible for marking routes as active and
@@ -12,14 +13,21 @@ abstract class RoutingService<T, Config extends Object> extends Service {
1213 /// Returns the root route of the application with all its nested routes expanded.
1314 Route <T , Config > get root;
1415
16+ /// Required for the factory pattern to work.
17+ @internal
18+ RoutingService .internal ();
19+
1520 /// Navigates to the specified [path] and invokes the [callback] with the built presentation.
1621 /// If [skipPreview] is true, the preview phase is skipped and [callback] is called only after the final build phase.
1722 Future <void > navigate (
1823 String path, {
1924 bool skipPreview = false ,
20- required void Function (T , bool ) callback,
25+ void Function (T , bool ) callback = noopCallback ,
2126 });
2227
28+ /// Default callback for [navigate] .
29+ static void noopCallback (dynamic _, bool _) {}
30+
2331 /// Checks if the specified [path] is currently active.
2432 ///
2533 /// If [exact] is true (default), checks for an exact match; otherwise, checks for a partial match.
@@ -56,6 +64,16 @@ abstract class RoutingService<T, Config extends Object> extends Service {
5664 StreamSubscription <ViewChangedEvent <T , Config >> onViewChanged (
5765 void Function (ViewChangedEvent <T , Config >) callback,
5866 );
67+
68+ /// A stream of all view change events.
69+ Stream <ViewChangedEvent <T , Config >> get viewStream;
70+
71+ /// Returns the DI-registered implementation of [RoutingService] .
72+ ///
73+ /// Shorthand for [Service.get] .
74+ factory RoutingService () {
75+ return Service .get <RoutingService <T , Config >>();
76+ }
5977}
6078
6179/// An event representing a change in the view rendered by the [RoutingService] .
0 commit comments