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


TypeScript operations.remove函數代碼示例

本文整理匯總了TypeScript中@dojo/framework/stores/state/operations.remove函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript remove函數的具體用法?TypeScript remove怎麽用?TypeScript remove使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了remove函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: get

const preSortCommand = commandFactory<SortCommandPayload>(({ at, path, get, payload: { id, columnId, direction } }) => {
	const page = get(path(id, 'meta', 'page'));
	return [
		remove(path(id, 'data', 'pages')),
		replace(path(id, 'meta', 'fetchedPages'), page === 1 ? [1] : [page, page - 1]),
		replace(path(id, 'meta', 'sort', 'columnId'), columnId),
		replace(path(id, 'meta', 'sort', 'direction'), direction),
		replace(path(id, 'meta', 'isSorting'), true)
	];
});
開發者ID:bryanforbes,項目名稱:widgets,代碼行數:10,代碼來源:processes.ts

示例2: async

	async ({ at, path, get, payload: { id, fetcher, page, pageSize } }) => {
		let result: FetcherResult;
		const isSorting = get(path(id, 'meta', 'isSorting'));
		if (!isSorting) {
			const sortOptions = get(path(id, 'meta', 'sort'));
			const filterOptions = get(path(id, 'meta', 'filter'));
			try {
				result = await fetcher(page, pageSize, { sort: sortOptions, filter: filterOptions });
			} catch (error) {
				return [remove(path(id, 'data', 'pages', `page-${page}`))];
			}
			return [
				replace(path(id, 'data', 'pages', `page-${page}`), result.data),
				replace(path(id, 'meta', 'total'), result.meta.total),
				replace(path(id, 'meta', 'pageSize'), pageSize)
			];
		} else {
			throw Error('The grid is being sorted or filtered');
		}
	}
開發者ID:dojo,項目名稱:widgets,代碼行數:20,代碼來源:processes.ts

示例3: get

const deleteCommentCommand = commandFactory<DeleteCommentPayload>(async ({ at, get, path, payload: { slug, id } }) => {
	const token = get(path('user', 'token'));
	await fetch(`${baseUrl}/articles/${slug}/comments/${id}`, {
		method: 'delete',
		headers: getHeaders(token)
	});
	const comments = get(path('article', 'comments'));
	let index = -1;
	for (let i = 0; i < comments.length; i++) {
		if (comments[i].id === id) {
			index = i;
			break;
		}
	}

	if (index !== -1) {
		return [remove(at(path('article', 'comments'), index))];
	}
	return [];
});
開發者ID:dojo,項目名稱:examples,代碼行數:20,代碼來源:articleProcesses.ts

示例4: async

	async ({ at, path, get, payload: { id, fetcher, columnId, value } }) => {
		const pageSize = get(path(id, 'meta', 'pageSize'));
		const sortOptions = get(path(id, 'meta', 'sort'));
		let result: FetcherResult;
		try {
			result = await fetcher(1, pageSize, { sort: sortOptions, filter: { columnId, value } });
		} catch (err) {
			return [];
		}
		const filterOptions = get(path(id, 'meta', 'filter'));
		if (filterOptions.columnId !== columnId || filterOptions.value !== value) {
			throw new Error();
		}
		return [
			remove(path(id, 'data', 'pages')),
			replace(path(id, 'data', 'pages', 'page-1'), result.data),
			replace(path(id, 'meta', 'filter', 'columnId'), columnId),
			replace(path(id, 'meta', 'filter', 'value'), value),
			replace(path(id, 'meta', 'total'), result.meta.total),
			replace(path(id, 'meta', 'isSorting'), false)
		];
	}
開發者ID:bryanforbes,項目名稱:widgets,代碼行數:22,代碼來源:processes.ts

示例5: remove

		...keys.filter(key => todos[key].completed).map(key => remove(path('todos', key)))
開發者ID:dojo,項目名稱:examples,代碼行數:1,代碼來源:todoProcesses.ts

示例6: commandFactory

const removeTodoCommand = commandFactory(({ payload: { id }, path }): PatchOperation[] => {
	return [ remove(path('todos', id)) ];
});
開發者ID:dojo,項目名稱:examples,代碼行數:3,代碼來源:todoProcesses.ts


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