本文整理汇总了TypeScript中@dojo/framework/stores/Store.Store.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Store.get方法的具体用法?TypeScript Store.get怎么用?TypeScript Store.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@dojo/framework/stores/Store.Store
的用法示例。
在下文中一共展示了Store.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should filter', async () => {
const fetcherStub = stub();
fetcherStub.returns({
data: [{ id: '1' }],
meta: {
total: 10000
}
});
store.apply([{ op: OperationType.REPLACE, path: new Pointer(['grid', 'meta', 'page']), value: 10 }]);
await filterProcess(store)({ filterOptions: { columnId: 'id', value: 'filter' }, id: 'grid', fetcher: fetcherStub });
const pages = store.get(store.path('grid', 'data'));
assert.deepEqual(pages, { pages: { 'page-1': [{ id: '1' }] } });
const meta = store.get(store.path('grid', 'meta'));
assert.deepEqual(meta, {
currentFilter: {
columnId: 'id',
value: 'filter'
},
page: 1,
filter: { id: 'filter' },
fetchedPages: [1],
isSorting: false,
total: 10000
});
});
示例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: switch
router.on('outlet', ({ outlet, action }) => {
if (action === 'enter') {
switch (outlet.id) {
case 'user':
if (outlet.isExact()) {
getProfileProcess(store)({ username: outlet.params.username });
fetchFeedProcess(store)({ type: 'user', page: 0, filter: outlet.params.username });
}
break;
case 'favorites':
getProfileProcess(store)({ username: outlet.params.username });
fetchFeedProcess(store)({ type: 'favorites', page: 0, filter: outlet.params.username });
break;
case 'article':
getArticleProcess(store)({ slug: outlet.params.slug });
break;
case 'settings':
getUserSettingsProcess(store)({});
break;
case 'edit-post':
getEditorArticleProcess(store)({ slug: outlet.params.slug });
break;
case 'home':
const isAuthenticated = !!store.get(store.path('user', 'token'));
fetchFeedProcess(store)({ type: isAuthenticated ? 'feed' : 'global', page: 0, filter: '' });
break;
}
} else {
if (outlet.id === 'edit-post') {
clearEditorProcess(store)({});
}
}
});