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