当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Store.Store类代码示例

本文整理汇总了TypeScript中@dojo/framework/stores/Store.Store的典型用法代码示例。如果您正苦于以下问题:TypeScript Store类的具体用法?TypeScript Store怎么用?TypeScript Store使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Store类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

	it('should use store from properties when passed', () => {
		const store = new Store();
		const filterableConfig = [{ id: 'id', title: 'id', filterable: true }];
		const h = harness(() =>
			w(MockMetaMixin(Grid, mockMeta), {
				fetcher: noop,
				updater: noop,
				columnConfig: filterableConfig,
				store,
				height: 500
			})
		);

		h.expect(() =>
			v('div', { key: 'root', classes: [css.root, fixedCss.rootFixed], role: 'table', 'aria-rowcount': null }, [
				v('div', {
					key: 'header',
					scrollLeft: 0,
					classes: [css.header, fixedCss.headerFixed, css.filterGroup],
					row: 'rowgroup'
				}, [
					w(Header, {
						key: 'header-row',
						columnConfig: filterableConfig,
						sorter: noop,
						sort: undefined,
						filter: undefined,
						filterer: noop
					})
				]),
				w(Body, {
					key: 'body',
					pages: {},
					totalRows: undefined,
					pageSize: 100,
					columnConfig: filterableConfig,
					pageChange: noop,
					updater: noop,
					fetcher: noop,
					onScroll: noop,
					height: 300
				}),
				v('div', { key: 'footer' }, [
					w(Footer, {
						key: 'footer-row',
						total: undefined,
						page: 1,
						pageSize: 100
					})
				])
			])
		);

		store.apply(
			[
				{
					op: OperationType.REPLACE,
					path: new Pointer('_grid/data/pages/page-1'),
					value: [{ id: 'id' }]
				},
				{
					op: OperationType.REPLACE,
					path: new Pointer('_grid/meta'),
					value: {
						page: 10,
						sort: {
							columnId: 'id',
							direction: 'asc'
						},
						filter: {
							columnId: 'id',
							value: 'id'
						},
						total: 100
					}
				}
			],
			true
		);

		h.expect(() =>
			v('div', { key: 'root', classes: [css.root, fixedCss.rootFixed], role: 'table', 'aria-rowcount': '100' }, [
				v('div', {
					key: 'header',
					scrollLeft: 0,
					classes: [css.header, fixedCss.headerFixed, css.filterGroup],
					row: 'rowgroup'
				}, [
					w(Header, {
						key: 'header-row',
						columnConfig: filterableConfig,
						sorter: noop,
						sort: {
							columnId: 'id',
							direction: 'asc'
						},
						filter: {
							columnId: 'id',
							value: 'id'
						},
//.........这里部分代码省略.........
开发者ID:bryanforbes,项目名称:widgets,代码行数:101,代码来源:Grid.ts

示例2: filterProcess

		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
			});
		});
开发者ID:dojo,项目名称:widgets,代码行数:25,代码来源:processes.ts

示例3:

		it('Should not fail if the page is already set', () => {
			pageChangeProcess(store)({ id: 'grid', page: 2 });
			let page = store.get(store.path('grid', 'meta', 'page'));
			assert.strictEqual(page, 2);
			pageChangeProcess(store)({ id: 'grid', page: 2 });
			page = store.get(store.path('grid', 'meta', 'page'));
			assert.strictEqual(page, 2);
		});
开发者ID:dojo,项目名称:widgets,代码行数:8,代码来源:processes.ts

示例4: 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);
		}
	}
}
开发者ID:dojo,项目名称:examples,代码行数:10,代码来源:main.ts

示例5: fetcherProcess

		it('fetcher should update the page and meta data for request', async () => {
			const fetcherStub = stub();
			fetcherStub.returns({
				data: [{ id: '1' }],
				meta: {
					total: 10000
				}
			});
			await fetcherProcess(store)({ id: 'grid', page: 2, fetcher: fetcherStub, pageSize: 100 });
			const pages = store.get(store.path('grid', 'data'));
			assert.deepEqual(pages, { pages: { 'page-2': [{ id: '1' }] } });
			const meta = store.get(store.path('grid', 'meta'));
			assert.deepEqual(meta, { fetchedPages: [2], total: 10000, pageSize: 100 });
		});
开发者ID:dojo,项目名称:widgets,代码行数:14,代码来源:processes.ts

示例6:

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)({});
		}
	}
});
开发者ID:dojo,项目名称:examples,代码行数:33,代码来源:main.ts

示例7: sortProcess

		it('should sort', 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 sortProcess(store)({ columnId: 'id', direction: 'asc', id: 'grid', fetcher: fetcherStub });
			const pages = store.get(store.path('grid', 'data'));
			assert.deepEqual(pages, { pages: { 'page-9': [{ id: '1' }], 'page-10': [{ id: '1' }] } });
			const meta = store.get(store.path('grid', 'meta'));
			assert.deepEqual(meta, {
				page: 10,
				sort: { columnId: 'id', direction: 'asc' },
				fetchedPages: [10, 9],
				isSorting: false,
				total: 10000
			});
		});
开发者ID:dojo,项目名称:widgets,代码行数:21,代码来源:processes.ts

示例8: updaterProcess

		it('Should update item', async () => {
			const updaterStub = stub();
			store.apply([
				{
					op: OperationType.REPLACE,
					path: new Pointer(['grid', 'data', 'pages', 'page-1']),
					value: [{ id: 'A', name: 'bill' }]
				}
			]);
			let pages = store.get(store.path('grid', 'data'));
			assert.deepEqual(pages, { pages: { 'page-1': [{ id: 'A', name: 'bill' }] } });
			await updaterProcess(store)({
				updater: updaterStub,
				columnId: 'name',
				id: 'grid',
				value: 'foo',
				page: 1,
				rowNumber: 0
			});
			pages = store.get(store.path('grid', 'data'));
			assert.deepEqual(pages, { pages: { 'page-1': [{ id: 'A', name: 'foo' }] } });
		});
开发者ID:dojo,项目名称:widgets,代码行数:22,代码来源:processes.ts


注:本文中的@dojo/framework/stores/Store.Store类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。