prague-fluent
Advanced tools
Comparing version 0.16.2 to 0.16.3
@@ -18,3 +18,3 @@ import { Matcher, Observableable, Predicate, Router } from './FluentRouter'; | ||
and<TRANSFORMRESULT>(recognizer: IfMatchesFluent<ROUTABLE, TRANSFORMRESULT>): IfMatchesFluent<ROUTABLE, TRANSFORMRESULT>; | ||
thenDo(thenHandler: (routable: ROUTABLE, value: VALUE) => Observableable<any>): IfMatchesThen<ROUTABLE, VALUE>; | ||
thenDo(thenHandler: (routable: ROUTABLE, value: VALUE) => Observableable<any>, score?: number): IfMatchesThen<ROUTABLE, VALUE>; | ||
thenTry(router: Router<ROUTABLE>): IfMatchesThen<ROUTABLE, VALUE>; | ||
@@ -21,0 +21,0 @@ thenTry(getRouter: (routable: ROUTABLE, value: VALUE) => Router<ROUTABLE>): IfMatchesThen<ROUTABLE, VALUE>; |
@@ -63,4 +63,4 @@ "use strict"; | ||
}; | ||
IfMatchesFluent.prototype.thenDo = function (thenHandler) { | ||
return this.thenTry(function (_routable, value) { return FluentRouter_1.Router.do(function (routable) { return thenHandler(routable, value); }); }); | ||
IfMatchesFluent.prototype.thenDo = function (thenHandler, score) { | ||
return this.thenTry(function (_routable, value) { return FluentRouter_1.Router.do(function (routable) { return thenHandler(routable, value); }, score); }); | ||
}; | ||
@@ -67,0 +67,0 @@ IfMatchesFluent.prototype.thenTry = function (arg) { |
{ | ||
"name": "prague-fluent", | ||
"version": "0.16.2", | ||
"version": "0.16.3", | ||
"description": "fluent API for Prague", | ||
@@ -5,0 +5,0 @@ "main": "dist/fluent.js", |
@@ -63,4 +63,7 @@ import { konsole, Matcher, Observableable, toObservable, Predicate, Handler, GetRoute$, Router } from './FluentRouter'; | ||
thenDo(thenHandler: (routable: ROUTABLE, value: VALUE) => Observableable<any>) { | ||
return this.thenTry((_routable, value) => Router.do(routable => thenHandler(routable, value))); | ||
thenDo( | ||
thenHandler: (routable: ROUTABLE, value: VALUE) => Observableable<any>, | ||
score?: number | ||
) { | ||
return this.thenTry((_routable, value) => Router.do(routable => thenHandler(routable, value), score)); | ||
} | ||
@@ -67,0 +70,0 @@ |
@@ -734,2 +734,18 @@ "use strict"; | ||
}); | ||
it("should return the handler's score", (done) => { | ||
let handled; | ||
ifTrue(c => ({ value: true, score: .25 })) | ||
.thenDo((c, value) => { | ||
handled = value; | ||
}, .4) | ||
._getRoute$(foo) | ||
.subscribe(route => { | ||
console.log("route", route); | ||
expect(route.score).to.eql(.1); | ||
route.action(); | ||
expect(handled).to.be.true; | ||
}, passErr, done); | ||
}); | ||
}); | ||
@@ -961,3 +977,2 @@ | ||
}); | ||
}); | ||
@@ -964,0 +979,0 @@ |
Sorry, the diff of this file is not supported yet
56273
1367