當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Subject.asObservable方法代碼示例

本文整理匯總了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();
 }
開發者ID:corrieb,項目名稱:vic,代碼行數:10,代碼來源:vm-view.service.ts

示例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);
                }
            }
        });
    }
開發者ID:aGautrain,項目名稱:ZetaPush-quizz,代碼行數:50,代碼來源:quizz.service.ts

示例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();
    }
開發者ID:CaringIsCreepy,項目名稱:VSTS-Mobile,代碼行數:29,代碼來源:build-service.ts

示例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);
        }
    }
開發者ID:prashanthc97,項目名稱:kylo,代碼行數:37,代碼來源:preview-schema.service.ts

示例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();
 }
開發者ID:CaringIsCreepy,項目名稱:VSTS-Mobile,代碼行數:26,代碼來源:team-project-service.ts

示例6: constructor

 constructor(private googleApiService: GoogleApiService) {
     this.isSignedInSubject = new Subject<boolean>();
     this.isSignedIn$ = this.isSignedInSubject.asObservable();
     
     this._isSignedIn = this.googleApiService.isSignedIn();
     this.initIsAuthorizedPromise();
 }
開發者ID:omostepaniuk,項目名稱:godiap,代碼行數:7,代碼來源:authentication.service.ts

示例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));
 }
開發者ID:CaselIT,項目名稱:angular2-modal,代碼行數:7,代碼來源:base-dynamic-component.ts

示例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);
        }
    }
開發者ID:prashanthc97,項目名稱:kylo,代碼行數:30,代碼來源:preview-raw.service.ts

示例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();
  }
開發者ID:CaringIsCreepy,項目名稱:VSTS-Mobile,代碼行數:28,代碼來源:login-service.ts

示例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();
  }
開發者ID:cinovo,項目名稱:cloudconductor-server,代碼行數:8,代碼來源:alert-stub.ts


注:本文中的rxjs/Subject.Subject.asObservable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。