本文整理汇总了TypeScript中angular.IIntervalService类的典型用法代码示例。如果您正苦于以下问题:TypeScript IIntervalService类的具体用法?TypeScript IIntervalService怎么用?TypeScript IIntervalService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IIntervalService类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: D2FarmingService
export function D2FarmingService(
$rootScope: IRootScopeService,
$q: IQService,
dimItemService: ItemServiceType,
D2StoresService: StoreServiceType,
$interval: IIntervalService,
toaster,
$i18next
) {
'ngInject';
let intervalId;
let subscription;
const outOfSpaceWarning = _.throttle((store) => {
toaster.pop('info',
$i18next.t('FarmingMode.OutOfRoomTitle'),
$i18next.t('FarmingMode.OutOfRoom', { character: store.name }));
}, 60000);
function getMakeRoomBuckets() {
return getBuckets().then((buckets) => {
return Object.values(buckets.byHash).filter((b) => b.category === 3 && b.type);
});
}
return {
active: false,
store: null,
movingItems: false,
makingRoom: false,
// Ensure that there's one open space in each category that could
// hold an item, so they don't go to the postmaster.
async makeRoomForItems(store: DimStore) {
const makeRoomBuckets = await getMakeRoomBuckets();
// If any category is full, we'll move one aside
let itemsToMove: DimItem[] = [];
makeRoomBuckets.forEach((makeRoomBucket) => {
const items = store.buckets[makeRoomBucket.id];
if (items.length > 0 && items.length >= makeRoomBucket.capacity) {
// We'll move the lowest-value item to the vault.
const itemToMove = _.min(items.filter((i) => !i.equipped && !i.notransfer), (i) => {
let value = {
Common: 0,
Uncommon: 1,
Rare: 2,
Legendary: 3,
Exotic: 4
}[i.tier];
// And low-stat
if (i.primStat) {
value += i.primStat.value / 1000;
}
return value;
});
if (!_.isNumber(itemToMove)) {
itemsToMove.push(itemToMove);
}
}
});
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);
}
});
//.........这里部分代码省略.........
开发者ID:delphiactual,项目名称:DIM,代码行数:101,代码来源:d2farming.service.ts
示例2: Date
vm.$onInit = () => {
vm.endTime = new Date(vm.endTime);
// Update once a minute
vm.timer = $interval(update, 60000);
update();
};
开发者ID:bhollis,项目名称:DIM,代码行数:7,代码来源:countdown.component.ts
示例3: 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
示例4:
vm.$onInit = () => {
this.lastNbNotification = -1;
// schedule an automatic refresh of the user notifications
if (!vm.notificationsScheduler) {
vm.refreshUserNotifications();
vm.notificationsScheduler = $interval(() => {
vm.refreshUserNotifications();
}, UserNotificationService.getNotificationSchedulerInSeconds() * 1000);
}
};
开发者ID:gravitee-io,项目名称:gravitee-management-webui,代码行数:10,代码来源:portalnotifications.component.ts
示例5: function
vm.startTasks = function(user) {
if (user.authenticated) {
vm.graviteeUser = user;
// schedule an automatic refresh of the user tasks
if (!vm.tasksScheduler) {
vm.refreshUserTasks();
vm.tasksScheduler = $interval(() => {
vm.refreshUserTasks();
}, TaskService.getTaskSchedulerInSeconds() * 1000);
}
}
};
开发者ID:gravitee-io,项目名称:gravitee-management-webui,代码行数:12,代码来源:navbar.component.ts
示例6:
vm.$onDestroy = () => {
$interval.cancel(vm.timer);
};
开发者ID:bhollis,项目名称:DIM,代码行数:3,代码来源:countdown.component.ts
示例7: function
vm.cancelRefreshUserNotifications = function() {
if (vm.notificationsScheduler) {
$interval.cancel(vm.notificationsScheduler);
vm.notificationsScheduler = undefined;
}
};
开发者ID:gravitee-io,项目名称:gravitee-management-webui,代码行数:6,代码来源:portalnotifications.component.ts
示例8: Game
ctrl.$onInit = (): void => {
ctrl.game = new Game();
ctrl.updateTimer = $interval(tickMethod, GameSettings.tick);
ctrl.fixedUpdateTimer = $interval(fixedTickMethod, 1000);
}
开发者ID:jkachurek,项目名称:jkachurek.github.io,代码行数:5,代码来源:app.ts
注:本文中的angular.IIntervalService类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论