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


TypeScript IIntervalService.cancel方法代碼示例

本文整理匯總了TypeScript中angular.IIntervalService.cancel方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IIntervalService.cancel方法的具體用法?TypeScript IIntervalService.cancel怎麽用?TypeScript IIntervalService.cancel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在angular.IIntervalService的用法示例。


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

示例1: update

 function update() {
   const diff = vm.endTime.getTime() - Date.now();
   vm.text = dhms(diff / 1000);
   if (diff <= 0) {
     $interval.cancel(vm.timer);
   }
 }
開發者ID:bhollis,項目名稱:DIM,代碼行數:7,代碼來源:countdown.component.ts

示例2: function

 vm.cancelRefreshUserTasks = function() {
   if (vm.tasksScheduler) {
     $interval.cancel(vm.tasksScheduler);
     vm.tasksScheduler = undefined;
   }
 };
開發者ID:gravitee-io,項目名稱:gravitee-management-webui,代碼行數:6,代碼來源:navbar.component.ts

示例3: function

 vm.cancelRefreshUserNotifications = function() {
   if (vm.notificationsScheduler) {
     $interval.cancel(vm.notificationsScheduler);
     vm.notificationsScheduler = undefined;
   }
 };
開發者ID:gravitee-io,項目名稱:gravitee-management-webui,代碼行數:6,代碼來源:portalnotifications.component.ts

示例4:

 vm.$onDestroy = () => {
   $interval.cancel(vm.timer);
 };
開發者ID:bhollis,項目名稱:DIM,代碼行數:3,代碼來源:countdown.component.ts

示例5: D2FarmingService


//.........這裏部分代碼省略.........

      if (settings.farming.moveTokens) {
        itemsToMove = itemsToMove.concat(store.items.filter((i) => REP_TOKENS.has(i.hash)));
      }

      if (itemsToMove.length === 0) {
        return $q.resolve();
      }

      return moveItemsToVault(store, itemsToMove, makeRoomBuckets);
    },

    async farm(store: DimStore) {
      this.makingRoom = true;
      try {
        // Then make room for items
        await this.makeRoomForItems(store);
      } finally {
        this.makingRoom = false;
      }
    },

    start(account: DestinyAccount, storeId: string) {
      if (!this.active) {
        this.active = true;
        this.movingItems = false;
        this.makingRoom = false;

        // Whenever the store is reloaded, run the farming algo
        // That way folks can reload manually too
        subscription = D2StoresService.getStoresStream(account).subscribe((stores) => {
          // prevent some recursion...
          if (this.active && !this.movingItems && !this.makingRoom && stores) {
            const store = stores.find((s) => s.id === storeId);
            this.store = store;
            this.farm(store);
          }
        });

        intervalId = $interval(() => {
          // just start reloading stores more often
          $rootScope.$broadcast('dim-refresh');
        }, 60000);
      }
    },

    stop() {
      if (intervalId) {
        $interval.cancel(intervalId);
      }
      if (subscription) {
        subscription.unsubscribe();
        subscription = null;
      }
      this.active = false;
      this.store = null;
    }
  };

  async function moveItemsToVault(store: DimStore, items: DimItem[], makeRoomBuckets: DimInventoryBucket[]) {
    const reservations = {};
    // reserve one space in the active character
    reservations[store.id] = {};
    makeRoomBuckets.forEach((bucket) => {
      reservations[store.id][bucket.type!] = 1;
    });

    for (const item of items) {
      try {
        // Move a single item. We reevaluate each time in case something changed.
        const vault = D2StoresService.getVault()!;
        const vaultSpaceLeft = vault.spaceLeftForItem(item);
        if (vaultSpaceLeft <= 1) {
          // If we're down to one space, try putting it on other characters
          const otherStores = D2StoresService.getStores().filter((s) => !s.isVault && s.id !== store.id);
          const otherStoresWithSpace = otherStores.filter((store) => store.spaceLeftForItem(item));

          if (otherStoresWithSpace.length) {
            if ($featureFlags.debugMoves) {
              console.log("Farming initiated move:", item.amount, item.name, item.type, 'to', otherStoresWithSpace[0].name, 'from', D2StoresService.getStore(item.owner)!.name);
            }
            await dimItemService.moveTo(item, otherStoresWithSpace[0], false, item.amount, items, reservations);
            continue;
          }
        }
        if ($featureFlags.debugMoves) {
          console.log("Farming initiated move:", item.amount, item.name, item.type, 'to', vault.name, 'from', D2StoresService.getStore(item.owner)!.name);
        }
        await dimItemService.moveTo(item, vault, false, item.amount, items, reservations);
      } catch (e) {
        if (e.code === 'no-space') {
          outOfSpaceWarning(store);
        } else {
          toaster.pop('error', item.name, e.message);
        }
        throw e;
      }
    }
  }
}
開發者ID:delphiactual,項目名稱:DIM,代碼行數:101,代碼來源:d2farming.service.ts


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