本文整理汇总了TypeScript中@dojo/shim/global.sessionStorage类的典型用法代码示例。如果您正苦于以下问题:TypeScript sessionStorage类的具体用法?TypeScript sessionStorage怎么用?TypeScript sessionStorage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sessionStorage类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: commandFactory
const registerCommand = commandFactory(async ({ get, path }) => {
const requestPayload = {
user: get(path('register'))
};
const response = await fetch(`${baseUrl}/users`, {
method: 'post',
body: JSON.stringify(requestPayload),
headers: getHeaders()
});
const json = await response.json();
if (!response.ok) {
return [
replace(path('register', 'failed'), true),
replace(path('register', 'loading'), false),
replace(path('errors'), json.errors),
replace(path('user'), {})
];
}
global.sessionStorage.setItem('conduit-session', JSON.stringify(json.user));
return [
replace(path('routing', 'outlet'), 'home'),
replace(path('register', 'loading'), false),
replace(path('errors'), undefined),
replace(path('user'), json.user),
replace(path('feed', 'items'), undefined),
replace(path('feed', 'loaded'), false)
];
});
示例2: async
return module.LoginContainer;
});
registry.define('register', async () => {
const module = await import('./containers/RegisterContainer');
return module.RegisterContainer;
});
registry.define('profile', async () => {
const module = await import('./containers/ProfileContainer');
return module.ProfileContainer;
});
registry.define('settings', async () => {
const module = await import('./containers/SettingsContainer');
return module.SettingsContainer;
});
const session = global.sessionStorage.getItem('conduit-session');
getTagsProcess(store)({});
if (session) {
setSessionProcess(store)({ session: JSON.parse(session) });
}
router.on('nav', ({ outlet, context }: any) => {
changeRouteProcess(store)({ outlet, context });
});
function onRouteChange() {
const outlet = store.get(store.path('routing', 'outlet'));
const params = store.get(store.path('routing', 'params'));
if (outlet) {
const link = router.link(outlet, params);