本文整理汇总了TypeScript中common/types.IStore类的典型用法代码示例。如果您正苦于以下问题:TypeScript IStore类的具体用法?TypeScript IStore怎么用?TypeScript IStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IStore类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: dispatchUpdateNotification
function dispatchUpdateNotification(
store: IStore,
item: CheckUpdateItem,
result: CheckUpdateResult
) {
if (!result) {
return;
}
if (!isEmpty(result.warnings)) {
store.dispatch(
actions.statusMessage({
message: [
"status.game_update.check_failed",
{ err: result.warnings[0] },
],
})
);
return;
}
if (isEmpty(result.updates)) {
store.dispatch(
actions.statusMessage({
message: ["status.game_update.not_found", { title: item.game.title }],
})
);
} else {
store.dispatch(
actions.statusMessage({
message: ["status.game_update.found", { title: item.game.title }],
})
);
}
}
示例2: restoreTabs
export async function restoreTabs(store: IStore, profile: Profile) {
const profileId = profile.id;
const { value, ok } = await call(messages.ProfileDataGet, {
profileId,
key: "@itch/tabs",
});
if (!ok) {
logger.info(`No tabs to restore`);
return;
}
try {
const snapshot = JSON.parse(value) as Snapshot;
if (!store.getState().preferences.enableTabs) {
if (snapshot.items.length > 1) {
snapshot.items = [snapshot.items[0]];
}
}
const validTabs = new Set(snapshot.items.map(x => x.id));
if (validTabs.has(snapshot.current)) {
store.dispatch(actions.tabsRestored(snapshot));
} else {
// nevermind
}
} catch (e) {
logger.warn(`Could not retrieve saved tabs: ${e.message}`);
return;
}
}
示例3: applyTabOffset
async function applyTabOffset(store: IStore, window: string, offset: number) {
const { tab, openTabs } = store.getState().windows[window].navigation;
const numTabs = openTabs.length;
const index = openTabs.indexOf(tab);
// adding numPaths takes care of negative wrapping too!
const newIndex = (index + offset + numTabs) % numTabs;
const newTab = openTabs[newIndex];
store.dispatch(actions.focusTab({ window, tab: newTab }));
}
示例4: push
function push(store: IStore, next: typeof actions.commonsUpdated.payload) {
const prev = store.getState().commons;
let hasDifferences = false;
for (const k of Object.keys(next)) {
if (!isEqual(prev[k], next[k])) {
hasDifferences = true;
break;
}
}
if (hasDifferences) {
store.dispatch(actions.commonsUpdated(next));
}
}
示例5: refreshButlerd
async function refreshButlerd(store: IStore) {
logger.info(`Refreshing butlerd! Spinning up new instance...`);
let instance = await makeButlerInstance();
instance.promise().catch(e => {
console.error(`butlerd instance threw:`);
console.error(e.stack);
refreshButlerd(store).catch(() => {});
});
const endpoint = await instance.getEndpoint();
logger.info(`Connecting client...`);
const nextClient = new Client(endpoint);
await nextClient.connect();
if (masterClient) {
// instances exit gracefully when all clients have closed
logger.info(`Closing old master client...`);
masterClient.close();
masterClient = null;
}
masterClient = nextClient;
logger.info(`Got new endpoint`);
store.dispatch(actions.gotButlerdEndpoint({ endpoint }));
initialButlerdResolve();
}
示例6: updateCommonsNowThrows
async function updateCommonsNowThrows(store: IStore) {
if (!store.getState().setup.done) {
return;
}
const { caves, downloadKeys, installLocations } = await call(
messages.FetchCommons,
{}
);
let locationSizes = {};
if (!isEmpty(installLocations)) {
for (const x of installLocations) {
locationSizes[x.id] = x.sizeInfo.installedSize;
}
}
push(store, {
caves: indexBy(caves, "id"),
caveIdsByGameId: groupIdBy(caves, "gameId"),
downloadKeys: indexBy(downloadKeys, "id"),
downloadKeyIdsByGameId: groupIdBy(downloadKeys, "gameId"),
locationSizes,
});
}
示例7: saveTabs
export async function saveTabs(store: IStore) {
const rs = store.getState();
const { navigation, tabInstances } = rs.windows["root"];
const { credentials } = rs.profile;
if (!credentials || !credentials.me) {
return;
}
const { tab, openTabs } = navigation;
const profileId = credentials.me.id;
let items: ITabDataSave[];
items = map(openTabs, id => {
const ti = tabInstances[id];
if (!ti) {
return null;
}
const sp = Space.fromInstance(ti);
const { history, currentIndex } = ti;
const savedLabel = sp.label();
return { id, history, currentIndex, savedLabel };
});
items = filter(items, x => !!x);
const snapshot: Snapshot = { current: tab, items };
await call(messages.ProfileDataPut, {
profileId,
key: "@itch/tabs",
value: JSON.stringify(snapshot),
});
}
示例8:
nativeWindow.on("enter-full-screen", (e: any) => {
const ns = store.getState().windows[window].native;
if (!ns.fullscreen) {
store.dispatch(
actions.windowFullscreenChanged({ window, fullscreen: true })
);
}
});