當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Store.apply方法代碼示例

本文整理匯總了TypeScript中@dojo/framework/stores/Store.Store.apply方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Store.apply方法的具體用法?TypeScript Store.apply怎麽用?TypeScript Store.apply使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@dojo/framework/stores/Store.Store的用法示例。


在下文中一共展示了Store.apply方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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
			});
		});
開發者ID:dojo,項目名稱:widgets,代碼行數:25,代碼來源:processes.ts

示例2: 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


注:本文中的@dojo/framework/stores/Store.Store.apply方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。