本文整理汇总了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)); }