当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript rx.Subject类代码示例

本文整理汇总了TypeScript中rx.Subject的典型用法代码示例。如果您正苦于以下问题:TypeScript Subject类的具体用法?TypeScript Subject怎么用?TypeScript Subject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Subject类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: model

export function model(action$: Rx.Observable<Action>, initialState: any) {
    let state$ = new Subject();
    action$
        //.scan(initialState, (state: any, actions: Action[]) => actions.reduce((s, action) => action.update(s), state))
        .scan(initialState, (s, action) => action.update(s))
        .subscribe(state$);
    return state$.startWith(initialState);
}
开发者ID:duncanmak,项目名称:experiments,代码行数:8,代码来源:model.ts

示例2: it

        it("should construct the right observable", () => {
            let dataSubject = new Rx.Subject<number>();
            dataSubject.subscribe(data => dataEmitted.push(data));
            subject.register<number>("Foo", parameters => {
                dataSubject.onNext(parameters.counter);
                return dataSubject;
            });
            subject.get<number>("Foo", { counter: 20 });

            expect(dataEmitted).to.eql([20]);
        });
开发者ID:lazyoft,项目名称:ninjagoat,代码行数:11,代码来源:ObservableFactorySpec.ts

示例3: oldFn

export function action < T extends Function, Return > (target: T & ICallable<Return>): T & ICallable<Return> & IAction<Return> {

    var oldFn = target
    var rx_action = new Rx.Subject<Return>()

    var newFn = (function (...args) {
        var retval = oldFn(...args)
        rx_action.onNext(retval)
        return retval
    } as any) as T & ICallable<Return> & IAction<Return>

    newFn.rx_action = rx_action.asObservable()
    return newFn
}
开发者ID:hungdluit,项目名称:luxor,代码行数:14,代码来源:action.ts

示例4: return

export function asyncAction < T extends Function, Return > (target: T & ICallable<Promise<Return>>): T & ICallable<Promise<Return>> & IAction<Return> {
    var oldFn = target
    var rx_action = new Rx.Subject<Return>()

    var newFn = (function (...args) {
        return (oldFn(...args) as any).then(val => {
            rx_action.onNext(val as any)
            return val
        })
    } as any) as T & ICallable<Promise<Return>> & IAction<Return>

    newFn.rx_action = rx_action.asObservable()

    return newFn
}
开发者ID:hungdluit,项目名称:luxor,代码行数:15,代码来源:action.ts

示例5: addMediaEvents

    const sub$ = Rx.Observable.combineLatest(...days).subscribe(data => {
      const totals = addMediaEvents(data.map(d => d.mediaEvent));

      data$.onNext(data);
      totals$.onNext(totals);
      sub$.dispose();
    });
开发者ID:guardian,项目名称:video-dashboard,代码行数:7,代码来源:app.ts

示例6: function

 request<any>(options, function(err, response) {
   if(err) {
     observable.onError(err);
   } else {
     observable.onNext(response.body);        
   }
 })
开发者ID:dghijben,项目名称:dashboard,代码行数:7,代码来源:Api.ts

示例7: Error

		connection.on("message", (message: WebSocketMessage) => {
			if (message.type == "utf8") {
				this.onMessage_.onNext({ string: message.utf8Data });
			} else if (message.type == "binary") {
				this.onMessage_.onNext({ data: bufferToData(message.binaryData) });
			} else {
				throw new Error(`invalid message ${message.type}`);
			}
		});
开发者ID:omochi,项目名称:national-economy,代码行数:9,代码来源:SocketImpl.ts

示例8: function

 socket.on(name + id, function([value, error, completed]) {
   if (completed) {
     observer.onCompleted()
   } else if (error) {
     observer.onError(error)
   } else {
     observer.onNext(value)
   }
 }).emit(name + id, true)
开发者ID:christyharagan,项目名称:uservices-socket.io-server,代码行数:9,代码来源:remoteProxy.ts


注:本文中的rx.Subject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。