本文整理汇总了TypeScript中common/util/watcher.Watcher.onDebounced方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Watcher.onDebounced方法的具体用法?TypeScript Watcher.onDebounced怎么用?TypeScript Watcher.onDebounced使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common/util/watcher.Watcher
的用法示例。
在下文中一共展示了Watcher.onDebounced方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
export default function(watcher: Watcher) {
watcher.onDebounced(
actions.tabsChanged,
tabAutoSaveThreshold,
async (store, action) => {
await saveTabs(store);
}
);
}
示例2: function
export default function(watcher: Watcher) {
watcher.on(actions.boot, async (store, action) => {
// load initial locales
const configPayload = await readFile(localesConfigPath);
const config = JSON.parse(configPayload);
store.dispatch(actions.localesConfigLoaded(config));
await loadLocale(store, "en");
});
watcher.onDebounced(
actions.queueLocaleDownload,
2000,
async (store, action) => {
let { lang, implicit } = action.payload;
const downloading = store.getState().i18n.downloading;
if (downloading[lang]) {
return;
}
store.dispatch(actions.localeDownloadStarted({ lang }));
let resources = {};
try {
resources = await doDownloadLocale(lang, resources, { implicit });
} catch (e) {
logger.warn(`Failed downloading locale for ${lang}: ${e.message}`);
} finally {
commitLocale(store, lang, resources);
}
}
);
watcher.on(actions.languageChanged, async (store, action) => {
const { lang } = action.payload;
await loadLocale(store, lang);
});
watcher.on(actions.reloadLocales, async (store, action) => {
const { lang } = store.getState().i18n;
logger.info(`Reloading locales...`);
await loadLocale(store, lang);
});
}