本文整理汇总了TypeScript中@dojo/framework/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: add
import { getTagsProcess } from './processes/tagProcesses';
import { setSessionProcess } from './processes/loginProcesses';
import { State } from './interfaces';
import config from './routes';
import { changeRouteProcess } from './processes/routeProcesses';
const store = new Store<State>();
let session;
if (!exists("build-time-render")) {
add("build-time-render", false);
}
if (!has('build-time-render')) {
session = global.sessionStorage.getItem('conduit-session');
}
if (session) {
setSessionProcess(store)({ session: JSON.parse(session) });
}
getTagsProcess(store)({});
const registry = registerStoreInjector(store);
const router = registerRouterInjector(config, registry);
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'));