當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。