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


TypeScript Store.first方法代码示例

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


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

示例1: subractMinutes

 subractMinutes(value) {
   this.store.first().subscribe(state => {
     const time = state.search.time.time;
     const newTime = subtractMinutes(time, value);
     this.store.dispatch(new ChangeDatetime(newTime))
   });
 }
开发者ID:bwhiting2356,项目名称:fiits,代码行数:7,代码来源:search.service.ts

示例2: subtractDay

 subtractDay() {
   this.store.first().subscribe(state => {
     const date = state.search.time.time;
     const dateDate = subtractDay(date);
     this.store.dispatch(new ChangeDatetime(dateDate))
   });
 }
开发者ID:bwhiting2356,项目名称:fiits,代码行数:7,代码来源:search.service.ts

示例3: confirmBook

 confirmBook() {
   this.store
     .first()
     .map(state => state.search.result.response.tripId)
     .subscribe(tripId => {
       this.store.dispatch(new ConfirmBook({ tripId }))
     })
 }
开发者ID:bwhiting2356,项目名称:fiits,代码行数:8,代码来源:search.service.ts

示例4: switchInputs

  switchInputs() {
    this.store.first().subscribe(state => {
      const originAddress = state.search.origin.address;
      const originCoords = state.search.origin.coords;
      const destinationAddress = state.search.destination.address;
      const destinationCoords = state.search.destination.coords;

      this.destinationChange(originAddress, originCoords);
      this.originChange(destinationAddress, destinationCoords);
      this.updateInputFocus();
    });
  }
开发者ID:bwhiting2356,项目名称:fiits,代码行数:12,代码来源:search.service.ts

示例5: updateInputFocus

 updateInputFocus() {
   this.store.first().subscribe(state => {
     if (state.search.origin.address.length === 0) {
       // console.log("this happened 320")
       this.originFocus();
     } else if (state.search.destination.address.length === 0) {
       this.destinationFocus();
     } else {
       this.noFocus();
     }
   });
 }
开发者ID:bwhiting2356,项目名称:fiits,代码行数:12,代码来源:search.service.ts

示例6: hmrOnDestroy

  public hmrOnDestroy(store): void {
    var cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
    // recreate elements
    store.disposeOldHosts = createNewHosts(cmpLocation);
    // save input values
    ///store.restoreInputValues  = createInputTransfer();
    // remove styles
    removeNgStyles();

    this.appStore
      .first()
      .subscribe(snapshot => store.state = snapshot);
  }
开发者ID:kemins,项目名称:ps3,代码行数:13,代码来源:Module.ts

示例7: backOneStep

 backOneStep() {
   this.store.first().subscribe(state => {
     let newProgress: string;
     switch (state.search.progress) {
       case ProgressSteps.PENDING_1:
       case ProgressSteps.VIEWING_RESULT:
       case ProgressSteps.ERROR_1:
         newProgress = ProgressSteps.NO_SEARCH;
         break;
       case ProgressSteps.READING_INFO:
         newProgress = ProgressSteps.VIEWING_RESULT;
         break;
       case ProgressSteps.PENDING_2:
       case ProgressSteps.NO_SEARCH:
       case ProgressSteps.BOOKING_SUCCESS:
       case ProgressSteps.ERROR_2:
         break;
     }
     this.store.dispatch(new NavigateToStep(newProgress))
   });
 }
开发者ID:bwhiting2356,项目名称:fiits,代码行数:21,代码来源:search.service.ts

示例8: searchSubmit

  searchSubmit() {
    this.store.first().subscribe(state => {
      const request: TripQueryRequest = {
        originAddress: state.search.origin.address,
        originCoords: state.search.origin.coords,
        destinationAddress: state.search.destination.address,
        destinationCoords: state.search.destination.coords,
        time: state.search.time.time,
        timeTarget: state.search.time.timeTarget
      };
      this.store.dispatch(new SubmitQuery(request));
    });

    // this.ngRedux.dispatch({ type: SEARCH_SUBMIT });
    // this.ngRedux.dispatch({ type: MAP_RENDERING_START });

    // const state: IAppState = this.ngRedux.getState();
    //
    // if (state.searchOriginAddress && state.searchDestinationAddress) {
    //   // TODO: check if new trip query is the same as the old trip query before sending
    //   // TODO: throttle events when requests keep changing? Client side or server side?
    //
    //   const tripQueryRequest = buildTripQueryRequest(state);
    //   this.http.post('http://localhost:3000/api/trip-query', tripQueryRequest).subscribe(response => {
    //     const tripQueryResponse = parseTripQueryResponse(response);
    //
    //     this.ngRedux.dispatch({ type: SEARCH_RESULT_RECEIVED, body: tripQueryResponse });
    //     this.ngRedux.dispatch({ type: MAP_RENDERING_STOP });
    //
    //     // TODO: refactor into a better function, also account for possibly the destination being current location
    //
    //     // update address or keep as current location
    //
    //     this.ngRedux.dispatch({ type: SEARCH_DESTINATION_CHANGE, body: {
    //       address: tripQueryResponse.destinationAddress,
    //       coords: tripQueryResponse.destinationCoords
    //     }});
    //   }, (err) => {
    //     console.log(err);
    //   });
    //
    //   // setTimeout(() => {    // fake right now
    //   //   this.ngRedux.dispatch({ type: SEARCH_RESULT_RECEIVED, body: tripQueryResponse });
    //   //   this.fitboundsService.setMapBounds();
    //   //
    //   //   this.mapService.addWalking1Directions(
    //   //     tripQueryResponse.startLocation,
    //   //     tripQueryResponse.station1Location);
    //   //
    //   //   this.mapService.addBikeDirections(
    //   //     tripQueryResponse.station1Location,
    //   //     tripQueryResponse.station2Location);
    //   //
    //   //   this.mapService.addWalking2Directions(
    //   //     tripQueryResponse.station2Location,
    //   //     tripQueryResponse.endLocation);
    //   //
    //   //   // TODO: get directions on the server side, send list of points back with the response data
    //   //
    //   //   this.ngRedux.dispatch({ type: MAP_RENDERING_STOP });
    //   //
    //   // }, 100)
    //
    //   // setTimeout(() => {
    //   //   this.ngRedux.dispatch({ type: SEARCH_ERROR_RECEIVED , body: 'Error message' })
    //   // }, 1000)
    // } else {
    //   // this.ngRedux.dispatch({ type: SEARCH_CANCEL_FETCH });
    //   this.ngRedux.dispatch({ type: MAP_RENDERING_STOP });
    // }
  }
开发者ID:bwhiting2356,项目名称:fiits,代码行数:71,代码来源:search.service.ts


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