本文整理匯總了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);