From 58ecf2003132c3eb1c55de2d60aefc96e8d946de Mon Sep 17 00:00:00 2001 From: Luke Rielley Date: Thu, 11 Jul 2019 10:08:27 +1000 Subject: [PATCH] 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 --- types/falcor-express/index.d.ts | 4 ++-- types/falcor-http-datasource/index.d.ts | 3 ++- types/falcor-json-graph/index.d.ts | 3 ++- types/falcor-router/falcor-router-tests.ts | 22 ++++++++++++++++++++++ types/falcor-router/index.d.ts | 14 +++++++++----- types/falcor/index.d.ts | 9 +++++---- types/falcor/test/index.ts | 3 +++ 7 files changed, 45 insertions(+), 13 deletions(-) diff --git a/types/falcor-express/index.d.ts b/types/falcor-express/index.d.ts index 7bd42aa1d8..f5b0494126 100644 --- a/types/falcor-express/index.d.ts +++ b/types/falcor-express/index.d.ts @@ -1,8 +1,8 @@ // Type definitions for falcor-express 0.1.2 // Project: https://github.com/Netflix/falcor-express -// Definitions by: Quramy +// Definitions by: Quramy , LukeRielley // Definitions: https://github.com/borisyankov/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.4 /// diff --git a/types/falcor-http-datasource/index.d.ts b/types/falcor-http-datasource/index.d.ts index 1b57c4329f..4aa26fab43 100644 --- a/types/falcor-http-datasource/index.d.ts +++ b/types/falcor-http-datasource/index.d.ts @@ -1,7 +1,8 @@ // Type definitions for falcor-http-datasource 0.1.3 // Project: https://github.com/Netflix/falcor-http-datasource -// Definitions by: Quramy +// Definitions by: Quramy , LukeRielley // Definitions: https://github.com/borisyankov/DefinitelyTyped +// TypeScript Version: 2.4 /// diff --git a/types/falcor-json-graph/index.d.ts b/types/falcor-json-graph/index.d.ts index 359e2976c2..b9c1189e4b 100644 --- a/types/falcor-json-graph/index.d.ts +++ b/types/falcor-json-graph/index.d.ts @@ -1,7 +1,8 @@ // Type definitions for falcor-json-graph 1.1.7 // Project: https://github.com/Netflix/falcor-json-graph -// Definitions by: Quramy +// Definitions by: Quramy , LukeRielley // Definitions: https://github.com/borisyankov/DefinitelyTyped +// TypeScript Version: 2.4 export = FalcorJsonGraph; diff --git a/types/falcor-router/falcor-router-tests.ts b/types/falcor-router/falcor-router-tests.ts index 7358ab2e02..1b3c073f3a 100644 --- a/types/falcor-router/falcor-router-tests.ts +++ b/types/falcor-router/falcor-router-tests.ts @@ -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[]}) { diff --git a/types/falcor-router/index.d.ts b/types/falcor-router/index.d.ts index 38da98a0a7..81da7d9ad5 100644 --- a/types/falcor-router/index.d.ts +++ b/types/falcor-router/index.d.ts @@ -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 , cdhgee +// Definitions by: Quramy +// cdhgee +// LukeRielley // Definitions: https://github.com/borisyankov/DefinitelyTyped +// TypeScript Version: 2.4 /// 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): CallRouteResult | Promise; + call(callPath: RoutePathSet, args: Array): CallRouteResult | Promise | Observable; } interface GetRoute extends Route { - get(pathset: RoutePathSet): RouteResult | Promise; + get(pathset: RoutePathSet): RouteResult | Promise | Observable; } interface SetRoute extends Route { - set(jsonGraph: FalcorJsonGraph.JSONGraph): RouteResult | Promise; + set(jsonGraph: FalcorJsonGraph.JSONGraph): RouteResult | Promise | Observable; } type RouteDefinition = GetRoute | SetRoute | CallRoute; diff --git a/types/falcor/index.d.ts b/types/falcor/index.d.ts index 72d900e213..940cabc971 100644 --- a/types/falcor/index.d.ts +++ b/types/falcor/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for falcor 0.1 -// Project: http://netflix.github.io/falcor/, https://github.com/netflix/falcor -// Definitions by: Quramy +// Type definitions for falcor 2.0 +// Project: https://netflix.github.io/falcor/, https://github.com/netflix/falcor +// Definitions by: Quramy , 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 extends Observable { constructor(observable: Observable); - progressively(): ModelResponse>; + progressively(): ModelResponse; forEach(onNext: (value: T) => void, onError?: (error: Error) => void, onCompleted?: () => void): Subscription; then(onFulfilled?: (value: T) => any | Thenable, onRejected?: (error: any) => void): Thenable; then(onFulfilled?: (value: T) => U | Thenable, onRejected?: (error: any) => void): Thenable; diff --git a/types/falcor/test/index.ts b/types/falcor/test/index.ts index 8eea62b2f2..a0e08c598e 100644 --- a/types/falcor/test/index.ts +++ b/types/falcor/test/index.ts @@ -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();