本文整理汇总了TypeScript中@dojo/stores/Store.Store类的典型用法代码示例。如果您正苦于以下问题:TypeScript Store类的具体用法?TypeScript Store怎么用?TypeScript Store使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Store类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
import { getTagsProcess } from './processes/tagProcesses';
import { setSessionProcess } from './processes/loginProcesses';
import { changeRouteProcess } from './processes/routeProcesses';
import { State } from './interfaces';
import { getRouteConfig } from './config';
class StoreInjector extends Injector {
constructor(payload: Store<State>) {
super(payload);
payload.on('invalidate', () => {
this.emit({ type: 'invalidate' });
});
}
}
const store = new Store<State>();
const registry = new Registry();
const router = registerRouterInjector(getRouteConfig(store), registry);
registry.define('editor', async () => {
const module = await import('./containers/EditorContainer');
return module.EditorContainer;
});
registry.define('article', async () => {
const module = await import('./containers/ArticleContainer');
return module.ArticleContainer;
});
registry.define('login', async () => {
const module = await import('./containers/LoginContainer');
return module.LoginContainer;
示例2: onRouteChange
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);
if (link !== undefined) {
router.setPath(link);
}
}
}
示例3:
onEnter: () => {
const isAuthenticated = !!store.get(store.path('user', 'token'));
fetchFeedProcess(store)({ type: isAuthenticated ? 'feed' : 'global', page: 0, filter: '' });
}