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
|
# 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)
|
![build status](https://travis-ci.org/angel-dart/route.svg)
|
||||||
|
|
||||||
A powerful, isomorphic routing library for Dart.
|
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;
|
Stream<Route> get onRoute => _onRoute.stream;
|
||||||
|
|
||||||
_BrowserRouterImpl({bool listen}) : super() {
|
_BrowserRouterImpl({bool listen}) : super() {
|
||||||
if (listen) this.listen();
|
if (listen != false) this.listen();
|
||||||
prepareAnchors();
|
prepareAnchors();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void go(List linkParams) => _goTo(navigate(linkParams));
|
void go(Iterable linkParams) => _goTo(navigate(linkParams));
|
||||||
|
|
||||||
void prepareAnchors() {
|
void prepareAnchors() {
|
||||||
final anchors = window.document.querySelectorAll('a:not([dynamic])');
|
final anchors = window.document.querySelectorAll('a:not([dynamic])');
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import 'router.dart';
|
import 'router.dart';
|
||||||
|
|
||||||
|
/// A chain of arbitrary handlers obtained by routing a path.
|
||||||
class MiddlewarePipeline {
|
class MiddlewarePipeline {
|
||||||
|
/// All the possible routes that matched the given path.
|
||||||
final List<RoutingResult> routingResults;
|
final List<RoutingResult> routingResults;
|
||||||
|
|
||||||
|
/// An ordered list of every handler delegated to handle this request.
|
||||||
List get handlers {
|
List get handlers {
|
||||||
final handlers = [];
|
final handlers = [];
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,30 @@
|
||||||
part of angel_route.src.router;
|
part of angel_route.src.router;
|
||||||
|
|
||||||
|
/// Represents a complex result of navigating to a path.
|
||||||
class RoutingResult {
|
class RoutingResult {
|
||||||
|
/// The Regex match that matched the given sub-path.
|
||||||
final Match match;
|
final Match match;
|
||||||
|
|
||||||
|
/// A nested instance, if a sub-path was matched.
|
||||||
final RoutingResult nested;
|
final RoutingResult nested;
|
||||||
|
|
||||||
|
/// All route params matching this route on the current sub-path.
|
||||||
final Map<String, dynamic> params = {};
|
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;
|
final Route shallowRoute;
|
||||||
|
|
||||||
|
/// The [Router] that answered this sub-path.
|
||||||
|
///
|
||||||
|
/// Only really for internal use.
|
||||||
final Router shallowRouter;
|
final Router shallowRouter;
|
||||||
|
|
||||||
|
/// The remainder of the full path that was not matched, and was passed to [nested] routes.
|
||||||
final String tail;
|
final String tail;
|
||||||
|
|
||||||
|
/// The [RoutingResult] that matched the most specific sub-path.
|
||||||
RoutingResult get deepest {
|
RoutingResult get deepest {
|
||||||
var search = this;
|
var search = this;
|
||||||
|
|
||||||
|
@ -16,13 +33,18 @@ class RoutingResult {
|
||||||
return search;
|
return search;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The most specific route.
|
||||||
Route get route => deepest.shallowRoute;
|
Route get route => deepest.shallowRoute;
|
||||||
|
|
||||||
|
/// The most specific router.
|
||||||
Router get router => deepest.shallowRouter;
|
Router get router => deepest.shallowRouter;
|
||||||
|
|
||||||
|
/// The handlers at this sub-path.
|
||||||
List get handlers {
|
List get handlers {
|
||||||
return []..addAll(shallowRouter.middleware)..addAll(shallowRoute.handlers);
|
return []..addAll(shallowRouter.middleware)..addAll(shallowRoute.handlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// All handlers on this sub-path and its children.
|
||||||
List get allHandlers {
|
List get allHandlers {
|
||||||
final handlers = [];
|
final handlers = [];
|
||||||
var search = this;
|
var search = this;
|
||||||
|
@ -35,6 +57,7 @@ class RoutingResult {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// All parameters on this sub-path and its children.
|
||||||
Map<String, dynamic> get allParams {
|
Map<String, dynamic> get allParams {
|
||||||
final params = {};
|
final params = {};
|
||||||
var search = this;
|
var search = this;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: angel_route
|
name: angel_route
|
||||||
description: A powerful, isomorphic routing library for Dart.
|
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>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/angel_route
|
homepage: https://github.com/angel-dart/angel_route
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|
Loading…
Reference in a new issue