本文整理汇总了TypeScript中rxjs/Subject.Subject.asObservable方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Subject.asObservable方法的具体用法?TypeScript Subject.asObservable怎么用?TypeScript Subject.asObservable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxjs/Subject.Subject
的用法示例。
在下文中一共展示了Subject.asObservable方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(
private http: Http,
private globalsService: GlobalsService
) {
// sets up subjects and observables
this.vchsSubj = new Subject<VirtualContainerHost[]>();
this.containersSubj = new Subject<ContainerVm[]>();
this.vchs$ = this.vchsSubj.asObservable();
this.containers$ = this.containersSubj.asObservable();
}
示例2: open
open() {
this._questions = new Subject();
this.questions = this._questions.asObservable();
this._scores = new Subject();
this.scores = this._scores.asObservable();
this._notifs = new Subject();
this.notifs = this._notifs.asObservable();
// Adding a listener
this.listener = this.zpClient.createService({
Type: services['Messaging'],
listener: {
message: (message) => {
console.debug('Received from server the following : ', message['data']['data']);
const communication: ServerCommunication = message['data']['data'];
switch(communication['type']){
case 'question':
this._questions.next(communication);
break;
case 'notification':
console.log('received a notif');
this._notifs.next(communication);
break;
case 'scores':
this._scores.next(communication['content']);
break;
case 'complete':
this._questions.complete();
break;
default:
console.log('Type of the communication unknown');
break;
}
},
error: (error) => {
console.error(error);
}
}
});
}
示例3: getList
getList() : Observable<BuildList> {
let subject = new Subject<BuildList>();
let returnValue = new BuildList();
let server = this.window.localStorage.getItem('server');
let teamProject = this.window.localStorage.getItem('project_name');
let url = server + '/DefaultCollection/' + teamProject + '/_apis/build/builds?api-version=2.0';
this.oAuthHttp.get(url).subscribe(res => {
let buildList = res.json();
for (var i = 0; i < buildList.value.length; i++) {
let build = new Build();
let buildDefinition = new BuildDefinition();
buildDefinition.populate(buildList.value[i].definition);
build.definition = buildDefinition;
build.status = buildList.value[i].status;
build.result = buildList.value[i].result;
build.finishTime = buildList.value[i].finishTime;
build.reason = buildList.value[i].reason;
returnValue.push(build);
}
subject.next(returnValue);
});
return subject.asObservable();
}
示例4: preview
/**
*
* Previews data abd populates the previewDataSet object
* @param {PreviewDataSet} previewDataSet
* @param {DataSetPreviewRequest} previewRequest
*/
preview(previewDataSet: PreviewDataSet, previewRequest: PreviewDataSetRequest):Observable<PreviewDataSet>{
if (!previewDataSet.hasPreview()) {
//Show Progress Bar
previewDataSet.loading = true;
let previewDataSetSource = new Subject<PreviewDataSet>()
let previewedDataSet$ = previewDataSetSource.asObservable();
this._transform(previewRequest,"/proxy/v1/spark/shell/preview").subscribe((data: TransformResponse) => {
let preview = this.transformResponeTableBuilder.buildTable(data);
previewDataSet.finishedLoading()
previewDataSet.clearPreviewError()
previewDataSet.schema = preview.columns;
previewDataSet.preview =preview;
previewDataSetSource.next(previewDataSet)
}, error1 => {
previewDataSet.finishedLoading()
previewDataSet.previewError("Error previewing the data " + error1);
previewDataSetSource.error(previewDataSet)
})
return previewedDataSet$;
}
else {
return Observable.of(previewDataSet);
}
}
示例5: getList
getList(): Observable<TeamProjectList> {
let subject = new Subject<TeamProjectList>();
var returnValue = new TeamProjectList();
let server = this.window.localStorage.getItem("server");
let url = server + "/DefaultCollection/_apis/projects?api-version=1.0";
this.oAuthHttp.get(url).subscribe(res => {
let projects = res.json();
for (let i = 0; i < projects.count; i++) {
let teamProject = new TeamProject();
teamProject.id = projects.value[i].id;
teamProject.name = projects.value[i].name;
teamProject.description = projects.value[i].description;
returnValue.push(teamProject);
}
subject.next(returnValue);
}, error => {
subject.error(error);
});
return subject.asObservable();
}
示例6: constructor
constructor(private googleApiService: GoogleApiService) {
this.isSignedInSubject = new Subject<boolean>();
this.isSignedIn$ = this.isSignedInSubject.asObservable();
this._isSignedIn = this.googleApiService.isSignedIn();
this.initIsAuthorizedPromise();
}
示例7: activateAnimationListener
activateAnimationListener() {
if (this.animationEnd) return;
this.animationEnd = new Subject<TransitionEvent | AnimationEvent>();
this.animationEnd$ = this.animationEnd.asObservable();
register('TransitionEnd', this.el.nativeElement, (e: TransitionEvent) => this.onEnd(e));
register('AnimationEnd', this.el.nativeElement, (e: AnimationEvent) => this.onEnd(e));
}
示例8: preview
preview(previewDataSet: PreviewFileDataSet) :Observable<PreviewDataSet>{
if(previewDataSet.raw == undefined && previewDataSet.allowsRawView) {
previewDataSet.loading=true;
let firstFile = previewDataSet.files[0].filePath;
let sparkScript = "var df = sqlContext.read.format(\"text\").load(\""+firstFile+"\")";
let previewDataSetSource = new Subject<PreviewDataSet>()
let previewedDataSet$ = previewDataSetSource.asObservable();
let sparkScriptWithLimit = this.limitSparkScript(sparkScript);
this.transform(sparkScriptWithLimit).subscribe((data: TransformResponse) => {
let preview = this.transformResponeTableBuilder.buildTable(data);
previewDataSet.raw = preview;
previewDataSet.clearRawError();
previewDataSet.finishedLoading()
previewDataSetSource.next(previewDataSet)
}, error1 => {
previewDataSet.finishedLoading()
previewDataSet.rawError("Error previewing the raw data " + error1)
previewDataSetSource.error(previewDataSet)
});
return previewedDataSet$;
}
else {
return Observable.of(previewDataSet);
}
}
示例9: refreshAuthToken
refreshAuthToken(): Observable<Response> {
let headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' });
let options = new RequestOptions({ headers: headers });
let subject = new Subject<Response>();
this.http.post(this.settings.ApplicationUrl + "refreshAuthToken",
"assertion=" + this.window.localStorage.getItem("refresh_token"), options).subscribe(res => {
let refreshPayload = res.json();
if (refreshPayload.access_token !== '' && refreshPayload.access_token !== undefined && refreshPayload.access_token !== null) {
this.window.localStorage.setItem("access_token", res.json().access_token);
this.window.localStorage.setItem("refresh_token", res.json().refresh_token);
let expirationDate = new Date();
expirationDate = new Date(expirationDate.getTime() + (res.json().expires_in * 1000));
this.window.localStorage.setItem("expiration_date", expirationDate.toString());
subject.next(res);
}
else {
subject.error(res);
}
}, error => { subject.error(error); });
return subject.asObservable();
}
示例10: getAlerts
public getAlerts(): Observable<Alert> {
let sub = new Subject<Alert>();
for (let i = 0; i < expectedAlerts.length; i++) {
sub.next(expectedAlerts[i]);
}
return sub.asObservable();
}