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


TypeScript store.store類代碼示例

本文整理匯總了TypeScript中app/store/store.store的典型用法代碼示例。如果您正苦於以下問題:TypeScript store類的具體用法?TypeScript store怎麽用?TypeScript store使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了store類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: updateLocation

 this.$rootScope.$on('$routeUpdate', (evt, data) => {
   const angularUrl = this.$location.url();
   const state = store.getState();
   if (state.location.url !== angularUrl) {
     store.dispatch(
       updateLocation({
         path: this.$location.path(),
         query: this.$location.search(),
         routeParams: this.$route.current.params,
       })
     );
   }
 });
開發者ID:grafana,項目名稱:grafana,代碼行數:13,代碼來源:bridge_srv.ts

示例2: init

  init() {
    this.$rootScope.$on('$routeUpdate', (evt, data) => {
      const angularUrl = this.$location.url();
      const state = store.getState();
      if (state.location.url !== angularUrl) {
        store.dispatch(
          updateLocation({
            path: this.$location.path(),
            query: this.$location.search(),
            routeParams: this.$route.current.params,
          })
        );
      }
    });

    this.$rootScope.$on('$routeChangeSuccess', (evt, data) => {
      store.dispatch(
        updateLocation({
          path: this.$location.path(),
          query: this.$location.search(),
          routeParams: this.$route.current.params,
        })
      );
    });

    // Listen for changes in redux location -> update angular location
    store.subscribe(() => {
      const state = store.getState();
      const angularUrl = this.$location.url();
      const url = locationUtil.stripBaseFromUrl(state.location.url);
      if (angularUrl !== url) {
        this.$timeout(() => {
          this.$location.url(url);
          // some state changes should not trigger new browser history
          if (state.location.replace) {
            this.$location.replace();
          }
        });
        console.log('store updating angular $location.url', url);
      }
    });

    appEvents.on('location-change', (payload: any) => {
      const urlWithoutBase = locationUtil.stripBaseFromUrl(payload.href);
      if (this.fullPageReloadRoutes.indexOf(urlWithoutBase) > -1) {
        this.$window.location.href = payload.href;
        return;
      }

      this.$timeout(() => {
        // A hack to use timeout when we're changing things (in this case the url) from outside of Angular.
        this.$location.url(urlWithoutBase);
      });
    });
  }
開發者ID:grafana,項目名稱:grafana,代碼行數:55,代碼來源:bridge_srv.ts

示例3: updateLocation

 const onViewPanel = () => {
   store.dispatch(
     updateLocation({
       query: {
         panelId: panel.id,
         edit: null,
         fullscreen: true,
       },
       partial: true,
     })
   );
 };
開發者ID:grafana,項目名稱:grafana,代碼行數:12,代碼來源:getPanelMenu.ts

示例4:

 store.subscribe(() => {
   const state = store.getState();
   const angularUrl = this.$location.url();
   const url = locationUtil.stripBaseFromUrl(state.location.url);
   if (angularUrl !== url) {
     this.$timeout(() => {
       this.$location.url(url);
       // some state changes should not trigger new browser history
       if (state.location.replace) {
         this.$location.replace();
       }
     });
     console.log('store updating angular $location.url', url);
   }
 });
開發者ID:grafana,項目名稱:grafana,代碼行數:15,代碼來源:bridge_srv.ts


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