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


TypeScript Subject.asObservable方法代码示例

本文整理汇总了TypeScript中rxjs/Rx.Subject.asObservable方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Subject.asObservable方法的具体用法?TypeScript Subject.asObservable怎么用?TypeScript Subject.asObservable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rxjs/Rx.Subject的用法示例。


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

示例1: isAuthenticated

 isAuthenticated(): Observable<boolean> {
   const subject = new Subject<boolean>();
   firebase.auth().onAuthStateChanged(function(user) {
     if (user) {
       subject.next(true);
     } else {
       subject.next(false);
     }
   });
   return subject.asObservable();
 }
开发者ID:Fishmore,项目名称:CookBook,代码行数:11,代码来源:auth.service.ts

示例2: open

	public open(message?: string): Observable<any> {
		if (message && message.length > 0) {
			this.message = message;
		}
		this.dialog.nativeElement.open();

		if (this._subject) {
			this._subject.complete();
		}
		this._subject = new Subject<boolean>();
		return this._subject.asObservable();
	}
开发者ID:Ingradi,项目名称:angular2-wine-app,代码行数:12,代码来源:confirm-dialog.component.ts

示例3: Subject

  return Observable.create(subscriber => {
    let source = this;

    let isEnabled = false;
    let closeBuffer = new Subject();
    let bufferIn = new Subject();

    // noinspection TypeScriptUnresolvedFunction
    let buffer = bufferIn.asObservable().buffer(closeBuffer.asObservable());
    buffer.subscribe(bufferedValues => {
      bufferedValues.forEach(val => subscriber.next(val));
    });

    pauseSignalObservable.subscribe(_isEnabled => {
      isEnabled = _isEnabled;
      if (isEnabled) {
        // flush buffer every when stream is enabled
        closeBuffer.next(0);
      }
    });

    let subscription = source.subscribe(value => {
        try {
          if (isEnabled) {
            subscriber.next(value);
          } else {
            bufferIn.next(value);
          }
        } catch (err) {
          subscriber.error(err);
        }
      },
      err => subscriber.error(err),
      () => subscriber.complete());
    return subscription;
  });
开发者ID:SuperheroicCoding,项目名称:angular2exploreRxJS,代码行数:36,代码来源:pausableBuffered.ts

示例4: registerDetails

  registerDetails(uid, firstname, lastname, email) {
    const subject = new Subject();

    this.sdkDb.child(uid).set({
      date: firebase.database['ServerValue']['TIMESTAMP'],
      regUser: uid,
      firstname: firstname,
      lastname: lastname,
      email: email
    })
      .then(
        val => {
          subject.next(val);
          subject.complete();

        },
        err => {
          subject.error(err);
          subject.complete();
        }
      );

    return subject.asObservable();
  }
开发者ID:gajaharan,项目名称:ANDlinked4,代码行数:24,代码来源:user.service.ts

示例5: constructor

 constructor() {
     this._popup = new Subject<BasePopup>();
     this.popup = this._popup.asObservable();
 }
开发者ID:it7-solutions,项目名称:networking-public-plugin,代码行数:4,代码来源:popup.service.ts

示例6:

 get todos$(): Observable<string[]> {
   return this._todos$.asObservable();
 }     
开发者ID:ryanlangton,项目名称:angular2-rxjs,代码行数:3,代码来源:todos.store.ts

示例7: events

 get events() {
     return this.eventStream.asObservable()
 }
开发者ID:aheinrich,项目名称:ng2-web-storage,代码行数:3,代码来源:indexeddb.service.ts

示例8:

 private get returner$() { return this.stateSubject$.asObservable().map(state => lodash.cloneDeep(state)); }
开发者ID:ovrmrw,项目名称:ng2-heroes-editor,代码行数:1,代码来源:store.ts


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