本文整理匯總了TypeScript中rxjs/Rx.Subject類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Subject類的具體用法?TypeScript Subject怎麽用?TypeScript Subject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Subject類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: doFileOperation
/**
* General method for performing the given operation (copy|move)
*
* @param action the action to perform (copy|move)
* @param type type of the content (content|folder)
* @param contentEntry the contentEntry which has to have the action performed on
* @param permission permission which is needed to apply the action
*/
private doFileOperation(action: string, type: string, contentEntry: MinimalNodeEntryEntity, permission?: string): Subject<string> {
const observable: Subject<string> = new Subject<string>();
if (this.contentService.hasPermission(contentEntry, permission)) {
const data: ContentNodeSelectorComponentData = {
title: `${action} ${contentEntry.name} to ...`,
currentFolderId: contentEntry.parentId,
rowFilter: this.rowFilter.bind(this, contentEntry.id),
imageResolver: this.imageResolver.bind(this),
select: new EventEmitter<MinimalNodeEntryEntity[]>()
};
this.dialog.open(ContentNodeSelectorComponent, { data, panelClass: 'adf-content-node-selector-dialog', width: '630px' });
data.select.subscribe((selections: MinimalNodeEntryEntity[]) => {
const selection = selections[0];
this.documentListService[`${action}Node`].call(this.documentListService, contentEntry.id, selection.id)
.subscribe(
observable.next.bind(observable, `OPERATION.SUCCES.${type.toUpperCase()}.${action.toUpperCase()}`),
observable.error.bind(observable)
);
this.dialog.closeAll();
});
return observable;
} else {
observable.error(new Error(JSON.stringify({ error: { statusCode: 403 } })));
return observable;
}
}
示例2: 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();
}
示例3: 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();
}
示例4: function
geocoder.geocode(options, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
geocode$.next(results);
} else {
geocode$.error(results);
}
});
示例5:
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
subject.next(true);
} else {
subject.next(false);
}
});
示例6: Error
collection.find({ _id: new ObjectID(id) }).limit(1).next((err: MongoError, user: TEntity): void => {
if (err) {
throw new Error(err.message);
}
subject.next(user);
subject.complete();
});
示例7: Error
.toArray((err: MongoError, users: Array<IUser>): void => {
if (err) {
throw new Error(err.message);
}
subject.next(users);
subject.complete();
});
示例8: setTimeout
setTimeout(() => {
const index = route.params['id'] - 1;
const course = coursesData.courses[index];
subject.next(course ? !course.pro : true);
subject.complete();
});