ALPHA ready :)
This commit is contained in:
parent
4e9454e0a2
commit
0e299518f1
6 changed files with 32 additions and 4 deletions
|
@ -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.
|
||||
|
|
2
analysis_options.yaml
Normal file
2
analysis_options.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
analyzer:
|
||||
strong-mode: true
|
|
@ -52,12 +52,12 @@ class _BrowserRouterImpl extends Router implements BrowserRouter {
|
|||
Stream<Route> 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])');
|
||||
|
|
|
@ -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<RoutingResult> routingResults;
|
||||
|
||||
/// An ordered list of every handler delegated to handle this request.
|
||||
List get handlers {
|
||||
final handlers = [];
|
||||
|
||||
|
|
|
@ -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<String, dynamic> 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<String, dynamic> get allParams {
|
||||
final params = {};
|
||||
var search = this;
|
||||
|
|
|
@ -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 <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/angel_route
|
||||
dev_dependencies:
|
||||
|
|
Loading…
Reference in a new issue