Falcor & dependencies: Support for Observable route results & progressive queries (#36647)

* fix: added support for 'progressively' and observable routes

* Updated contributors

* Updated contributors list for falcor-http-datasource
This commit is contained in:
Luke Rielley 2019-07-11 10:08:27 +10:00 committed by Armando Aguirre
parent a4194e1f7f
commit 58ecf20031
7 changed files with 45 additions and 13 deletions

View File

@ -1,8 +1,8 @@
// Type definitions for falcor-express 0.1.2
// Project: https://github.com/Netflix/falcor-express
// Definitions by: Quramy <https://github.com/Quramy>
// Definitions by: Quramy <https://github.com/Quramy>, LukeRielley <https://github.com/lukerielley>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.4
/// <reference types="falcor" />

View File

@ -1,7 +1,8 @@
// Type definitions for falcor-http-datasource 0.1.3
// Project: https://github.com/Netflix/falcor-http-datasource
// Definitions by: Quramy <https://github.com/Quramy>
// Definitions by: Quramy <https://github.com/Quramy>, LukeRielley <https://github.com/lukerielley>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// TypeScript Version: 2.4
/// <reference types="falcor" />

View File

@ -1,7 +1,8 @@
// Type definitions for falcor-json-graph 1.1.7
// Project: https://github.com/Netflix/falcor-json-graph
// Definitions by: Quramy <https://github.com/Quramy>
// Definitions by: Quramy <https://github.com/Quramy>, LukeRielley <https://github.com/lukerielley>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// TypeScript Version: 2.4
export = FalcorJsonGraph;

View File

@ -3,6 +3,7 @@
import falcor = require('falcor');
import Router = require('falcor-router');
import falcorJsonGraph = require('falcor-json-graph');
import { Observable } from 'rx';
new Router([]);
new Router([], {});
@ -68,6 +69,27 @@ new Router([{
}
}]);
new Router([{
route: 'todos.length',
get() {
return Observable.from({path: 'todos.length', value: 10});
},
}]);
new Router([{
route: 'todos.length',
get() {
return Observable.from({path: 'todos.length', value: 10});
},
}]);
new Router([{
route: 'todos.length',
get() {
return Observable.from({json: { todos: {length : 10}}});
},
}]);
new Router([{
route: 'todos[{integers:indicies}]',
get(pathset: Router.RoutePathSet & {indicies: number[]}) {

View File

@ -1,12 +1,16 @@
// Type definitions for falcor-router 0.4.0
// Type definitions for falcor-router 0.8
// Project: https://github.com/Netflix/falcor-router
// Definitions by: Quramy <https://github.com/Quramy>, cdhgee <https://github.com/cdhgee>
// Definitions by: Quramy <https://github.com/Quramy>
// cdhgee <https://github.com/cdhgee>
// LukeRielley <https://github.com/lukerielley>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// TypeScript Version: 2.4
/// <reference types="falcor" />
import * as FalcorModel from 'falcor';
import * as FalcorJsonGraph from 'falcor-json-graph';
import DataSource = FalcorModel.DataSource;
import { Observable } from 'rx';
declare class FalcorRouter extends DataSource {
@ -34,15 +38,15 @@ declare namespace FalcorRouter {
type RoutePathSet = FalcorJsonGraph.PathSet;
interface CallRoute extends Route {
call(callPath: RoutePathSet, args: Array<any>): CallRouteResult | Promise<CallRouteResult>;
call(callPath: RoutePathSet, args: Array<any>): CallRouteResult | Promise<CallRouteResult> | Observable<CallRouteResult>;
}
interface GetRoute extends Route {
get(pathset: RoutePathSet): RouteResult | Promise<RouteResult>;
get(pathset: RoutePathSet): RouteResult | Promise<RouteResult> | Observable<RouteResult>;
}
interface SetRoute extends Route {
set(jsonGraph: FalcorJsonGraph.JSONGraph): RouteResult | Promise<RouteResult>;
set(jsonGraph: FalcorJsonGraph.JSONGraph): RouteResult | Promise<RouteResult> | Observable<RouteResult>;
}
type RouteDefinition = GetRoute | SetRoute | CallRoute;

View File

@ -1,7 +1,8 @@
// Type definitions for falcor 0.1
// Project: http://netflix.github.io/falcor/, https://github.com/netflix/falcor
// Definitions by: Quramy <https://github.com/Quramy>
// Type definitions for falcor 2.0
// Project: https://netflix.github.io/falcor/, https://github.com/netflix/falcor
// Definitions by: Quramy <https://github.com/Quramy>, LukeRielley <https://github.com/lukerielley>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// TypeScript Version: 2.4
import { Path, PathSet, PathValue, JSONEnvelope, JSONGraph, JSONGraphEnvelope } from 'falcor-json-graph';
@ -217,7 +218,7 @@ export class Model {
export class ModelResponse<T> extends Observable<T> {
constructor(observable: Observable<T>);
progressively(): ModelResponse<JSONEnvelope<T>>;
progressively(): ModelResponse<T>;
forEach(onNext: (value: T) => void, onError?: (error: Error) => void, onCompleted?: () => void): Subscription;
then(onFulfilled?: (value: T) => any | Thenable<any>, onRejected?: (error: any) => void): Thenable<any>;
then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;

View File

@ -121,6 +121,9 @@ modelResponse.subscribe(res => res.json.items.length);
modelResponse.subscribe(res => res.json.items.length, error => console.error.bind(error));
modelResponse.subscribe(res => res.json.items.length, error => console.error.bind(error), () => null);
modelResponse.progressively().subscribe(res => res.json.items.length);
modelResponse.progressively().subscribe(res => res.json.items.length, error => console.error.bind(error), () => null);
const subscription = modelResponse.subscribe(res => res);
subscription.dispose();