当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Observable.map方法代码示例

本文整理汇总了TypeScript中rxjs/Rx.Observable.map方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Observable.map方法的具体用法?TypeScript Observable.map怎么用?TypeScript Observable.map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rxjs/Rx.Observable的用法示例。


在下文中一共展示了Observable.map方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor

 constructor(public store: Store<any[]>) {
   this.filteredTodos = Observable.combineLatest(store.select('todos'), store.select('visibility'), (todos: any, visibilityFilter: any) => todos.filter(visibilityFilter.filter));
   this.todos = store.select('todos');
   this.visibilityFilter = store.select('visibility');
   this.completedCount = this.todos.map((todos: any) => todos.reduce((count, todo) => todo.completed ? count + 1 : count, 0));
   this.activeCount = this.todos.map((todos: any) => todos.length - (todos.reduce((count, todo) => todo.completed ? count + 1 : count, 0)));
 }
开发者ID:Delapouite,项目名称:generator-fountain-angular2,代码行数:7,代码来源:MainSection.ts

示例2: ngOnInit

    ngOnInit() {
        this.codeList = this.tagList.tags$
            .map(tags => tags.map(tag => tag.id))
            .switchMap(tagIds => this.codeService.getAllCodes(tagIds));

        this.showList = this.codeList.map(codes => codes.length > 0);
        this.showEmptyMessage = this.showList.map(showList => !showList);
    }
开发者ID:idledrop,项目名称:code-irl-ui,代码行数:8,代码来源:code-list.component.ts

示例3: handleResponse

 protected handleResponse(entity: Observable<Response>): Observable<T> {
     return entity.map(this.extractData)
        .catch((err: any, caught: Observable<T>) => {
            if (this.config.handleError) this.config.handleError(err, caught);
            return Observable.throw(err);
        });
 }
开发者ID:gallayl,项目名称:angular2-odata,代码行数:7,代码来源:operation.ts

示例4: request

  request(url: string | Request, options?: RequestOptionsArgs): Observable<Response> {
    const tokenPromise: Promise<string> = this._keycloakService.getToken();
    const tokenObservable: Observable<string> = Observable.fromPromise(tokenPromise);

    if (typeof url === 'string') {
      return tokenObservable.map(token => {
        const authOptions = new RequestOptions({headers: new Headers({'Authorization': 'Bearer ' + token})});
        return new RequestOptions().merge(options).merge(authOptions);
      }).concatMap(opts => super.request(url, opts));
    } else if (url instanceof Request) {
      return tokenObservable.map(token => {
        url.headers.set('Authorization', 'Bearer ' + token);
        return url;
      }).concatMap(request => super.request(request));
    }
  }
开发者ID:chameleon82,项目名称:keycloak,代码行数:16,代码来源:keycloak.http.ts

示例5: createRequest

 private createRequest(type: string,data ?: Object) : Observable<any> {
   let _url : string = this.buildUrl(data);
   let _request : Observable<any>
   let stringParam : string = '';
   let _jsonBuild : any = {}
   if(_url.split('?')[1] && _url.split('?')[1].length) {
     (_url.split('?')[1].split('&')).forEach( _paramPart => {
       _jsonBuild[_paramPart.split('=')[0]] = _paramPart.split('=')[1];
     });
     stringParam = JSON.stringify(_jsonBuild);
   }
   switch (type) {
     case "post":
       _request = this._http.post(_url.split('?')[0], stringParam);
       break;
     case "patch":
       _request = this._http.patch(_url.split('?')[0], stringParam);
       break;
     case "put":
       _request = this._http.put(_url.split('?')[0], stringParam);
       break;
     case "delete":
       _request = this._http.delete(_url);
       break;
     case "head":
       _request = this._http.head(_url);
       break;
     default:
       _request = this._http.get(_url);
       break;
   }
   this._request = _request.map((response: Response) => response.json());
   return this._request;
 }
开发者ID:nino-c,项目名称:ng2-resource,代码行数:34,代码来源:index.ts

示例6:

export function invokeCommand<TObj extends ReactiveObject, TArg, TResult>(source: Observable<TArg>, obj: TObj, command: string | ReactiveCommand<TArg, TResult>): Observable<TResult> {
    var commandObservable: Observable<ReactiveCommand<TArg, TResult>>;
    var canExecute: Observable<boolean>;
    var isExecuting: Observable<boolean>;
    if (typeof command === "string") {
        // Make sure that the current command is observed
        commandObservable = obj.whenSingle(command, true).map(e => e.newPropertyValue);
        canExecute = commandObservable.map(c => c.canExecute).switch();
    } else {
        commandObservable = Observable.of(command);
        canExecute = command.canExecute;
    }
    var results = source
        .withLatestFrom(commandObservable, canExecute, (v1, command, canExecute) => {
            return {
                canExecute,
                command,
                observedValue: v1
            };
        })
        .filter(o => o.canExecute && o.command != null)
        .distinctUntilChanged()
        .flatMap(o => {
            return o.command.execute(o.observedValue);
        });
    return results;
}
开发者ID:KallynGowdy,项目名称:RxUI,代码行数:27,代码来源:invoke-command.ts

示例7: ngOnInit

 ngOnInit() {
    
     const peopleSignal: Observable<{}> = Observable.create(observer => {
         this.addNewPerson = () => observer.next();
     }).share();
     
     const startForm = [];
     for (let i = 0; i < 10000; i++){
         startForm[i] = new Form();
     }
     
     this.forms =  peopleSignal.map(() => [new Form()])
     .startWith(startForm)
     .scan((acc: Form[], value) => acc.concat(value));
      
     this.numberOfPeople = this.forms.map(forms => forms.length);
      
 }
开发者ID:LukaJCB,项目名称:Angular2RxBenchmark,代码行数:18,代码来源:list.component.ts

示例8: getUserLists

 // TODO There has to be a better way.
 /**
  *
  * @returns {Observable<R>}
  */
 public getUserLists(): Observable<Observable<FirebaseObjectObservable<any>[]>> {
   let userIdObservable: Observable<string> = this.authenticationService.observableUserId;
   return userIdObservable.map((uuid) => {
     return this.angularFire.database.list('users/' + uuid + '/task_lists').map((taskLists) => {
       return taskLists.map((taskList) => {
         return this.angularFire.database.object(TASK_LIST_METADATA_PATH + '/' + taskList['$key']);
       });
     });
   });
 }
开发者ID:hanaum,项目名称:choose_to_go,代码行数:15,代码来源:taskList.service.ts

示例9: constructor

 constructor(fb: FormBuilder) {
    
     const peopleSignal: Observable<{}> = Observable.create(observer => {
         this.addNewPerson = () => observer.next();
     });
     
     this.people =  peopleSignal.map(() => [new Person()])
     .startWith([new Person()])
     .scan((acc: Person[], value) => acc.concat(value));
      
 }
开发者ID:LukaJCB,项目名称:Angular2-FRP,代码行数:11,代码来源:person-list.component.ts

示例10: constructor

    constructor(
        private _http: Http,
        private _notes: NotificationsService,
        private _trackService: TrackService,
        private _configService: ConfigService
    ) {
        // Api base
        this._apiBase = _configService._baseApi + 'projects/';

        // Local datastore
        this._dataStore = {
            credits: [],
            trackCredits: [],
            selectedTrack: undefined
        };

        // Credits stream
        this.credits$ = new Observable(observer => this._creditsObserver = observer).share();

        // Update track credits when a new track is selected
        this._trackService.selectedTrack$.subscribe(selectedTrack => {
            this._dataStore.selectedTrack = selectedTrack;
            // Update track credits when a new track is selected
            this._creditsObserver.next(this._dataStore.credits);
        });

        // Track credits stream
        this.trackCredits$ = this.credits$.map(credits => this.getTrackCredits(credits));

        // Unique credits stream
        this.uniqCredits$ = this.credits$.map(credits => this.getUniqueCredits(credits));

        // Unused credits stream
        this.unusedCredits$ = this.credits$.map(credits => {
            let uniq = this.getUniqueCredits(credits);
            let trackCreds = this.getTrackCredits(credits);
            return uniq.filter(x =>
            trackCreds.filter(z => z.partyrealid === x.partyrealid && z.instrumentcode === x.instrumentcode).length === 0);
        });
    }
开发者ID:kiddieverts,项目名称:hl,代码行数:40,代码来源:credit.service.ts


注:本文中的rxjs/Rx.Observable.map方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。