From 0e299518f1257975d4d53356f2954c077dad98b7 Mon Sep 17 00:00:00 2001 From: thosakwe Date: Sun, 18 Dec 2016 23:43:55 -0500 Subject: [PATCH] ALPHA ready :) --- README.md | 2 +- analysis_options.yaml | 2 ++ lib/browser.dart | 4 ++-- lib/src/middleware_pipeline.dart | 3 +++ lib/src/routing_result.dart | 23 +++++++++++++++++++++++ pubspec.yaml | 2 +- 6 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 analysis_options.yaml diff --git a/README.md b/README.md index d11c8c37..ee467b63 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # angel_route -![version 1.0.0-dev+17](https://img.shields.io/badge/version-1.0.0--dev+17-red.svg) +![version 1.0.0-dev+18](https://img.shields.io/badge/version-1.0.0--dev+18-red.svg) ![build status](https://travis-ci.org/angel-dart/route.svg) A powerful, isomorphic routing library for Dart. diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 00000000..518eb901 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,2 @@ +analyzer: + strong-mode: true \ No newline at end of file diff --git a/lib/browser.dart b/lib/browser.dart index fe9330fa..6fb50754 100644 --- a/lib/browser.dart +++ b/lib/browser.dart @@ -52,12 +52,12 @@ class _BrowserRouterImpl extends Router implements BrowserRouter { Stream get onRoute => _onRoute.stream; _BrowserRouterImpl({bool listen}) : super() { - if (listen) this.listen(); + if (listen != false) this.listen(); prepareAnchors(); } @override - void go(List linkParams) => _goTo(navigate(linkParams)); + void go(Iterable linkParams) => _goTo(navigate(linkParams)); void prepareAnchors() { final anchors = window.document.querySelectorAll('a:not([dynamic])'); diff --git a/lib/src/middleware_pipeline.dart b/lib/src/middleware_pipeline.dart index b9a97188..e75d79a7 100644 --- a/lib/src/middleware_pipeline.dart +++ b/lib/src/middleware_pipeline.dart @@ -1,8 +1,11 @@ import 'router.dart'; +/// A chain of arbitrary handlers obtained by routing a path. class MiddlewarePipeline { + /// All the possible routes that matched the given path. final List routingResults; + /// An ordered list of every handler delegated to handle this request. List get handlers { final handlers = []; diff --git a/lib/src/routing_result.dart b/lib/src/routing_result.dart index aa604677..b70f2ff9 100644 --- a/lib/src/routing_result.dart +++ b/lib/src/routing_result.dart @@ -1,13 +1,30 @@ part of angel_route.src.router; +/// Represents a complex result of navigating to a path. class RoutingResult { + /// The Regex match that matched the given sub-path. final Match match; + + /// A nested instance, if a sub-path was matched. final RoutingResult nested; + + /// All route params matching this route on the current sub-path. final Map params = {}; + + /// The [Route] that answered this sub-path. + /// + /// This is mostly for internal use, and useless in production. final Route shallowRoute; + + /// The [Router] that answered this sub-path. + /// + /// Only really for internal use. final Router shallowRouter; + + /// The remainder of the full path that was not matched, and was passed to [nested] routes. final String tail; + /// The [RoutingResult] that matched the most specific sub-path. RoutingResult get deepest { var search = this; @@ -16,13 +33,18 @@ class RoutingResult { return search; } + /// The most specific route. Route get route => deepest.shallowRoute; + + /// The most specific router. Router get router => deepest.shallowRouter; + /// The handlers at this sub-path. List get handlers { return []..addAll(shallowRouter.middleware)..addAll(shallowRoute.handlers); } + /// All handlers on this sub-path and its children. List get allHandlers { final handlers = []; var search = this; @@ -35,6 +57,7 @@ class RoutingResult { return handlers; } + /// All parameters on this sub-path and its children. Map get allParams { final params = {}; var search = this; diff --git a/pubspec.yaml b/pubspec.yaml index 308522ee..9fe06eff 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: angel_route description: A powerful, isomorphic routing library for Dart. -version: 1.0.0-dev+17 +version: 1.0.0-dev+18 author: Tobe O homepage: https://github.com/angel-dart/angel_route dev_dependencies: