Merge pull request #15253 from cdhgee/master

Amend "call" route method signature to allow path/value pair based invalidation
This commit is contained in:
Nathan Shively-Sanders
2017-03-24 12:35:53 -07:00
committed by GitHub
2 changed files with 77 additions and 2 deletions
+74
View File
@@ -2,6 +2,7 @@
import falcor = require('falcor');
import Router = require('falcor-router');
import falcorJsonGraph = require('falcor-json-graph');
new Router([]);
new Router([], {});
@@ -100,3 +101,76 @@ new Router([{
}
}]);
new Router([{
route: 'todos.new',
call(callpath, args) {
return {path: 'json.todosById.1234.name', value: 'Buy cheese'};
}
}]);
new Router([{
route: 'todos.new',
call(callpath, args) {
return falcorJsonGraph.pathInvalidation('json.todos.length');
}
}]);
new Router([{
route: 'todos.new',
call(callpath, args) {
return [
falcorJsonGraph.pathInvalidation('json.todos.length'),
{path: 'json.todosById.1234.name', value: 'Buy cheese'}
]
}
}]);
new Router([{
route: 'todos.new',
call(callpath, args) {
return new Promise((resolve, reject): void => {
resolve([
falcorJsonGraph.pathInvalidation('json.todos.length'),
{path: 'json.todosById.1234.name', value: 'Buy cheese'}
]);
});
}
}]);
new Router([{
route: 'todos.new',
call(callpath, args) {
return {
paths: [['json', 'todosById', '1234', 'name']],
jsonGraph: {
json: {
todosById: {
1234: {
name: 'Buy cheese'
}
}
}
}
};
}
}]);
new Router([{
route: 'todos.new',
call(callpath, args) {
return new Promise((resolve, reject): void => {
resolve({
paths: [['json', 'todosById', '1234', 'name']],
jsonGraph: {
json: {
todosById: {
1234: {
name: 'Buy cheese'
}
}
}
}
});
});
}
}]);
+3 -2
View File
@@ -1,6 +1,6 @@
// Type definitions for falcor-router 0.4.0
// Project: https://github.com/Netflix/falcor-router
// Definitions by: Quramy <https://github.com/Quramy/>
// Definitions by: Quramy <https://github.com/Quramy/>, cdhgee <https://github.com/cdhgee/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference types="falcor" />
@@ -34,7 +34,7 @@ declare namespace FalcorRouter {
type RoutePathSet = FalcorJsonGraph.PathSet;
interface CallRoute extends Route {
call(callPath: RoutePathSet, args: Array<any>): RouteResult | Promise<RouteResult>;
call(callPath: RoutePathSet, args: Array<any>): CallRouteResult | Promise<CallRouteResult>;
}
interface GetRoute extends Route {
@@ -47,6 +47,7 @@ declare namespace FalcorRouter {
type RouteDefinition = GetRoute | SetRoute | CallRoute;
type RouteResult = FalcorJsonGraph.PathValue | Array<FalcorJsonGraph.PathValue> | FalcorJsonGraph.JSONEnvelope<any>;
type CallRouteResult = FalcorJsonGraph.PathValue | FalcorJsonGraph.InvalidPath | Array<FalcorJsonGraph.PathValue | FalcorJsonGraph.InvalidPath> | FalcorJsonGraph.JSONGraphEnvelope;
interface RouterOptions {
debug?: boolean;