本文整理匯總了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();
}
示例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();
}
示例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;
});
示例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();
}
示例5: constructor
constructor() {
this._popup = new Subject<BasePopup>();
this.popup = this._popup.asObservable();
}
示例6:
get todos$(): Observable<string[]> {
return this._todos$.asObservable();
}
示例7: events
get events() {
return this.eventStream.asObservable()
}
示例8:
private get returner$() { return this.stateSubject$.asObservable().map(state => lodash.cloneDeep(state)); }