Comparing version 0.16.0 to 0.16.1
@@ -48,3 +48,3 @@ import { konsole } from './Konsole'; | ||
export class Router <ROUTABLE> { | ||
constructor(public getRoute$: GetRoute$<ROUTABLE>) {} | ||
constructor(public _getRoute$: GetRoute$<ROUTABLE>) {} | ||
@@ -86,3 +86,3 @@ static actionRoute ( | ||
return router | ||
.getRoute$(routable) | ||
._getRoute$(routable) | ||
.do(route => konsole.log("route: returned a route", route)) | ||
@@ -125,3 +125,3 @@ .flatMap(route => route.type === 'action' | ||
return router | ||
.getRoute$(routable) | ||
._getRoute$(routable) | ||
.do(route => konsole.log(`first: router #${i} returned route`, route)); | ||
@@ -141,3 +141,3 @@ }) | ||
.takeWhile(_ => bestRoute.score < 1) | ||
.concatMap(router => router.getRoute$(routable)) | ||
.concatMap(router => router._getRoute$(routable)) | ||
.filter(route => route.type === 'action') | ||
@@ -221,3 +221,3 @@ .defaultIfEmpty(Router.noRoute('tryInScoreOrder')) | ||
? getThenRouter(routable, matchResult.value) | ||
.getRoute$(routable) | ||
._getRoute$(routable) | ||
.map(route => route.type === 'action' | ||
@@ -228,3 +228,3 @@ ? Router.routeWithCombinedScore(route, matchResult.score) | ||
: getElseRouter(routable, matchResult.reason) | ||
.getRoute$(routable) | ||
._getRoute$(routable) | ||
); | ||
@@ -261,4 +261,3 @@ } | ||
): GetRoute$<ROUTABLE> { | ||
return routable => | ||
Router.getRouteIfMatches$(Router.predicateToMatcher(predicate), getThenRouter, getElseRouter)(routable); | ||
return Router.getRouteIfMatches$(Router.predicateToMatcher(predicate), getThenRouter, getElseRouter); | ||
} | ||
@@ -271,3 +270,3 @@ | ||
return routable => router | ||
.getRoute$(routable) | ||
._getRoute$(routable) | ||
.map(route => route.type === 'action' | ||
@@ -288,3 +287,3 @@ ? { | ||
return routable => router | ||
.getRoute$(routable) | ||
._getRoute$(routable) | ||
.map(route => route.type === 'action' | ||
@@ -304,6 +303,6 @@ ? { | ||
): GetRoute$<ROUTABLE> { | ||
return routable => mainRouter.getRoute$(routable) | ||
return routable => mainRouter._getRoute$(routable) | ||
.flatMap(route => route.type === 'action' | ||
? Observable.of(route) | ||
: getDefaultRouter(routable, route.reason).getRoute$(routable) | ||
: getDefaultRouter(routable, route.reason)._getRoute$(routable) | ||
); | ||
@@ -320,5 +319,5 @@ } | ||
? Observable.of(Router.noRoute()) | ||
: router.getRoute$(routable) | ||
: router._getRoute$(routable) | ||
); | ||
} | ||
} |
@@ -28,4 +28,4 @@ import { Observable } from 'rxjs'; | ||
export declare class Router<ROUTABLE> { | ||
getRoute$: GetRoute$<ROUTABLE>; | ||
constructor(getRoute$: GetRoute$<ROUTABLE>); | ||
_getRoute$: GetRoute$<ROUTABLE>; | ||
constructor(_getRoute$: GetRoute$<ROUTABLE>); | ||
static actionRoute(action: () => Observableable<any>, score?: number): ActionRoute; | ||
@@ -32,0 +32,0 @@ static noRoute(reason?: string): NoRoute; |
@@ -22,4 +22,4 @@ "use strict"; | ||
var Router = /** @class */ (function () { | ||
function Router(getRoute$) { | ||
this.getRoute$ = getRoute$; | ||
function Router(_getRoute$) { | ||
this._getRoute$ = _getRoute$; | ||
} | ||
@@ -52,3 +52,3 @@ Router.actionRoute = function (action, score) { | ||
return router | ||
.getRoute$(routable) | ||
._getRoute$(routable) | ||
.do(function (route) { return Konsole_1.konsole.log("route: returned a route", route); }) | ||
@@ -77,3 +77,3 @@ .flatMap(function (route) { return route.type === 'action' | ||
return router | ||
.getRoute$(routable) | ||
._getRoute$(routable) | ||
.do(function (route) { return Konsole_1.konsole.log("first: router #" + i + " returned route", route); }); | ||
@@ -95,3 +95,3 @@ }) | ||
.takeWhile(function (_) { return bestRoute.score < 1; }) | ||
.concatMap(function (router) { return router.getRoute$(routable); }) | ||
.concatMap(function (router) { return router._getRoute$(routable); }) | ||
.filter(function (route) { return route.type === 'action'; }) | ||
@@ -158,3 +158,3 @@ .defaultIfEmpty(Router.noRoute('tryInScoreOrder')) | ||
? getThenRouter(routable, matchResult.value) | ||
.getRoute$(routable) | ||
._getRoute$(routable) | ||
.map(function (route) { return route.type === 'action' | ||
@@ -164,3 +164,3 @@ ? Router.routeWithCombinedScore(route, matchResult.score) | ||
: getElseRouter(routable, matchResult.reason) | ||
.getRoute$(routable); }); }; | ||
._getRoute$(routable); }); }; | ||
}; | ||
@@ -187,9 +187,7 @@ Router.predicateToMatcher = function (predicate) { | ||
Router.getRouteIfTrue$ = function (predicate, getThenRouter, getElseRouter) { | ||
return function (routable) { | ||
return Router.getRouteIfMatches$(Router.predicateToMatcher(predicate), getThenRouter, getElseRouter)(routable); | ||
}; | ||
return Router.getRouteIfMatches$(Router.predicateToMatcher(predicate), getThenRouter, getElseRouter); | ||
}; | ||
Router.getRouteBefore$ = function (beforeHandler, router) { | ||
return function (routable) { return router | ||
.getRoute$(routable) | ||
._getRoute$(routable) | ||
.map(function (route) { return route.type === 'action' | ||
@@ -201,3 +199,3 @@ ? __assign({}, route, { action: function () { return toObservable(beforeHandler(routable)) | ||
return function (routable) { return router | ||
.getRoute$(routable) | ||
._getRoute$(routable) | ||
.map(function (route) { return route.type === 'action' | ||
@@ -208,6 +206,6 @@ ? __assign({}, route, { action: function () { return toObservable(route.action()) | ||
Router.getRouteDefault$ = function (mainRouter, getDefaultRouter) { | ||
return function (routable) { return mainRouter.getRoute$(routable) | ||
return function (routable) { return mainRouter._getRoute$(routable) | ||
.flatMap(function (route) { return route.type === 'action' | ||
? rxjs_1.Observable.of(route) | ||
: getDefaultRouter(routable, route.reason).getRoute$(routable); }); }; | ||
: getDefaultRouter(routable, route.reason)._getRoute$(routable); }); }; | ||
}; | ||
@@ -219,3 +217,3 @@ Router.getRouteSwitch$ = function (getKey, mapKeyToRouter) { | ||
? rxjs_1.Observable.of(Router.noRoute()) | ||
: router.getRoute$(routable); }); }; | ||
: router._getRoute$(routable); }); }; | ||
}; | ||
@@ -222,0 +220,0 @@ Router.minRoute = Router.actionRoute(function () { |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "0.16.0", | ||
"version": "0.16.1", | ||
"description": "rules-based app engine", | ||
@@ -10,0 +10,0 @@ "main": "dist/prague.js", |
@@ -173,3 +173,3 @@ "use strict"; | ||
describe('router.getRoute$', () => { | ||
describe('router._getRoute$', () => { | ||
it('should return action route', done => { | ||
@@ -181,3 +181,3 @@ let theRoute = { | ||
new Router(routable => Observable.of(theRoute)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -194,3 +194,3 @@ expect(route).to.eql(theRoute); | ||
new Router(routable => Observable.of(theRoute)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -206,3 +206,3 @@ expect(route).to.eql(theRoute); | ||
routerDo(m => { handled = m; }) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -219,3 +219,3 @@ expect(route.type).to.eql('action'); | ||
routerDo(m => { handled = m; }, .5) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -251,3 +251,3 @@ expect(route.type).to.eql('action'); | ||
routerNo() | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -261,3 +261,3 @@ expect(route.type).to.eql('no'); | ||
routerNo('reason') | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -708,3 +708,3 @@ expect(route.type).to.eql('no'); | ||
)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -720,3 +720,3 @@ expect(route.score).to.eql(1); | ||
)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -733,3 +733,3 @@ expect(route.score).to.eql(.25); | ||
)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -746,3 +746,3 @@ expect(route.score).to.eql(1); | ||
)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -758,3 +758,3 @@ expect(route.score).to.eql(.5); | ||
)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(throwErr, error => { | ||
@@ -770,3 +770,3 @@ done(); | ||
)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(throwErr, error => { | ||
@@ -782,3 +782,3 @@ done(); | ||
)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -798,3 +798,3 @@ expect(route.reason).to.eql("none"); | ||
)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -812,3 +812,3 @@ expect(route.type === 'action'); | ||
)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -827,3 +827,3 @@ expect(route.type).to.eql('no'); | ||
)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -843,3 +843,3 @@ route.action(); | ||
)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -980,3 +980,3 @@ expect(route.type).to.eql('no') | ||
)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -993,3 +993,3 @@ expect(route.score).to.eql(1); | ||
)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -1018,3 +1018,3 @@ expect(route.score).to.eql(.4); | ||
)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -1030,3 +1030,3 @@ expect(route.score).to.eql(.25); | ||
)) | ||
.getRoute$(foo) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
@@ -1043,3 +1043,3 @@ expect(route.score).to.eql(.1); | ||
)) | ||
.getRoute$(notFoo) | ||
._getRoute$(notFoo) | ||
.subscribe(route => { | ||
@@ -1046,0 +1046,0 @@ expect(route.score).to.eql(.5); |
Sorry, the diff of this file is not supported yet
134811
2243