當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。