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


TypeScript reduxsauce.createReducer函数代码示例

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


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

示例1: createActions

 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import { createActions, createReducer } from 'reduxsauce';

export const { Types: MeasureTypes, Creators: MeasureActions } = createActions({
	activateMeasure: [],
	deactivateMeasure: [],
	setMeasureActive: ['isActive'],
	setDisabled: ['isDisabled'],
	setActiveSuccess: ['isActive'],
	setDisabledSuccess: ['isDisabled']
}, { prefix: 'MEASURE/' });

export const INITIAL_STATE = {
	isDisabled: false,
	isActive: false
};

export const setActiveSuccess = (state = INITIAL_STATE, { isActive }) => ({ ...state, isActive });

export const setDisabledSuccess = (state = INITIAL_STATE, { isDisabled }) => ({ ...state, isDisabled });

export const reducer = createReducer(INITIAL_STATE, {
	[MeasureTypes.SET_ACTIVE_SUCCESS]: setActiveSuccess,
	[MeasureTypes.SET_DISABLED_SUCCESS]: setDisabledSuccess
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:measure.redux.ts

示例2: updateRiskProps

		...state, componentState: {
			...state.componentState,
			sortOrder: state.componentState.sortOrder === 'asc' ? 'desc' : 'asc'
		}
	};
};

const showCloseInfo = (state = INITIAL_STATE, { riskId }) => {
	const risksMap = updateRiskProps(state.risksMap, riskId, { willBeClosed: true });
	return { ...state, risksMap };
};

export const resetComponentState = (state = INITIAL_STATE) => {
	return { ...state, componentState: INITIAL_STATE.componentState };
};

export const reducer = createReducer(INITIAL_STATE, {
	[RisksTypes.FETCH_RISKS_SUCCESS]: fetchRisksSuccess,
	[RisksTypes.FETCH_RISK_SUCCESS]: fetchRiskSuccess,
	[RisksTypes.FETCH_RISK_FAILURE]: fetchRiskFailure,
	[RisksTypes.SET_COMPONENT_STATE]: setComponentState,
	[RisksTypes.SAVE_RISK_SUCCESS]: saveRiskSuccess,
	[RisksTypes.TOGGLE_PENDING_STATE]: togglePendingState,
	[RisksTypes.RESET_COMPONENT_STATE]: resetComponentState,
	[RisksTypes.TOGGLE_DETAILS_PENDING_STATE]: toggleDetailsPendingState,
	[RisksTypes.CREATE_COMMENT_SUCCESS]: createCommentSuccess,
	[RisksTypes.UPDATE_COMMENT_SUCCESS]: updateCommentSuccess,
	[RisksTypes.DELETE_COMMENT_SUCCESS]: deleteCommentSuccess,
	[RisksTypes.TOGGLE_SORT_ORDER]: toggleSortOrder
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:risks.redux.ts

示例3: createReducer

export const INITIAL_STATE = {
	invoices: [],
	plans: [],
	subscriptions: [],
	billingInfo: {},
	isPending: true
};

const fetchPlansSuccess = (state = INITIAL_STATE, { plans }) =>
	Object.assign({}, state, { plans });

const fetchInvoicesSuccess = (state = INITIAL_STATE, { invoices }) =>
	Object.assign({}, state, { invoices, isPending: false });

const fetchSubscriptionsSuccess = (state = INITIAL_STATE, { subscriptions }) =>
	Object.assign({}, state, { subscriptions, isPending: false });

const fetchBillingInfoSuccess = (state = INITIAL_STATE, { billingInfo }) =>
	Object.assign({}, state, { billingInfo, isPending: false });

export const setPendingState = (state = INITIAL_STATE, { isPending }) =>
	Object.assign({}, state, { isPending });

export const reducer = createReducer(INITIAL_STATE, {
	[BillingTypes.SET_PENDING_STATE]: setPendingState,
	[BillingTypes.FETCH_PLANS_SUCCESS]: fetchPlansSuccess,
	[BillingTypes.FETCH_INVOICES_SUCCESS]: fetchInvoicesSuccess,
	[BillingTypes.FETCH_SUBSCRIPTIONS_SUCCESS]: fetchSubscriptionsSuccess,
	[BillingTypes.FETCH_BILLING_INFO_SUCCESS]: fetchBillingInfoSuccess
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:billing.redux.ts

示例4: createReducer

		return {
			user,
			permission: updatedPermissionKey
		};
	});

	currentProject.modelsPermissions = modelPermissions;

	return {...state, currentProject};
};

export const reducer = createReducer(INITIAL_STATE, {
	[UserManagementTypes.FETCH_TEAMSPACE_DETAILS_SUCCESS]: fetchTeamspaceDetailsSuccess,
	[UserManagementTypes.SET_PENDING_STATE]: setPendingState,
	[UserManagementTypes.ADD_USER_SUCCESS]: addUserSuccess,
	[UserManagementTypes.REMOVE_USER_SUCCESS]: removeUserSuccess,
	[UserManagementTypes.SET_TEAMSPACE]: setTeamspace,
	[UserManagementTypes.UPDATE_USER_JOB_SUCCESS]: updateUserJobSuccess,
	[UserManagementTypes.UPDATE_PERMISSIONS_SUCCESS]: updatePermissionsSuccess,
	[UserManagementTypes.GET_USERS_SUGGESTIONS_SUCCESS]: getUsersSuggestionsSuccess,
	[UserManagementTypes.CLEAR_USERS_SUGGESTIONS]: clearUsersSuggestions,

	// Project
	[UserManagementTypes.SET_PROJECT]: setProject,
	[UserManagementTypes.UPDATE_PROJECT_PERMISSIONS_SUCCESS]: updateProjectPermissionsSuccess,

	// Models
	[UserManagementTypes.FETCH_MODEL_PERMISSIONS_SUCCESS]: fetchModelPermissionsSuccess,
	[UserManagementTypes.UPDATE_MODEL_PERMISSIONS_SUCCESS]: updateModelPermissionsSuccess
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:userManagement.redux.ts

示例5: cloneDeep

	return { ...state, viewpointsMap };
};

const deleteViewpointSuccess = (state = INITIAL_STATE, { viewpointId }) => {
	const viewpointsMap = cloneDeep(state.viewpointsMap);
	delete viewpointsMap[viewpointId];

	return { ...state, viewpointsMap };
};

const showDeleteInfo = (state = INITIAL_STATE, { viewpointId }) => {
	const viewpointsMap = cloneDeep(state.viewpointsMap);
	viewpointsMap[viewpointId].willBeRemoved = true;

	return { ...state, viewpointsMap };
};

const setComponentState = (state = INITIAL_STATE, { componentState = {} }) => {
	return { ...state, componentState: {...state.componentState, ...componentState} };
};

export const reducer = createReducer(INITIAL_STATE, {
	[ViewpointsTypes.SET_PENDING_STATE]: setPendingState,
	[ViewpointsTypes.FETCH_VIEWPOINTS_SUCCESS]: fetchViewpointsSuccess,
	[ViewpointsTypes.CREATE_VIEWPOINT_SUCCESS]: createViewpointSuccess,
	[ViewpointsTypes.UPDATE_VIEWPOINT_SUCCESS]: updateViewpointSuccess,
	[ViewpointsTypes.DELETE_VIEWPOINT_SUCCESS]: deleteViewpointSuccess,
	[ViewpointsTypes.SHOW_DELETE_INFO]: showDeleteInfo,
	[ViewpointsTypes.SET_COMPONENT_STATE]: setComponentState
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:viewpoints.redux.ts

示例6: createActions

 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import { createActions, createReducer } from 'reduxsauce';
import { isString } from 'lodash';
import { SnackbarProps } from '@material-ui/core/Snackbar';

export const { Types: SnackbarTypes, Creators: SnackbarActions } = createActions({
	show: ['config']
}, { prefix: 'SNACKBAR/' });

export const INITIAL_STATE = {
	snackConfig: {} as SnackbarProps,
	isOpen: false
};

export const show = (state = INITIAL_STATE, action) => {
	const parsedConfig = isString(action.config) ? {message: action.config} : action.config;
	const config = {
		...parsedConfig,
		key: (new Date()).valueOf()
	};
	return { ...state, snackConfig: config, isOpen: true };
};

export const reducer = createReducer(INITIAL_STATE, {
	[SnackbarTypes.SHOW]: show
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:snackbar.redux.ts

示例7: createReducer

	initialised: false,
	visibleSources: []
};

export const initialiseMapSuccess = (state = INITIAL_STATE, { initialised }) => {
	return { ...state, initialised };
};

export const addSourceSuccess = (state = INITIAL_STATE, { source }) => {
	const visibleSources = [...state.visibleSources, source];
	return { ...state, visibleSources };
};

export const removeSourceSuccess = (state = INITIAL_STATE, { source }) => {
	const visibleSources = state.visibleSources.filter(
		(visibleSource) => visibleSource !== source);

	return { ...state, visibleSources };
};

export const resetSourcesSuccess = (state = INITIAL_STATE, {}) => {
	return { ...state, visibleSources: [] };
};

export const reducer = createReducer(INITIAL_STATE, {
	[GisTypes.INITIALISE_MAP_SUCCESS]: initialiseMapSuccess,
	[GisTypes.ADD_SOURCE_SUCCESS]: addSourceSuccess,
	[GisTypes.REMOVE_SOURCE_SUCCESS]: removeSourceSuccess,
	[GisTypes.RESET_SOURCES_SUCCESS]: resetSourcesSuccess
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:gis.redux.ts

示例8: createReducer

		currentTeamspace: userData.username,
		currentUser: userData,
		isAvatarPending: false
	};
};

const updateUserSuccess = (state = INITIAL_STATE, { userData }) => {
	const currentUser = { ...state.currentUser, ...userData };
	return { ...state, currentUser };
};

const refreshAvatar = (state = INITIAL_STATE, { avatarUrl }) => {
	const currentUser = { ...state.currentUser, avatarUrl };

	return {
		...state,
		currentUser,
		isAvatarPending: false
	};
};

export const reducer = createReducer({ ...INITIAL_STATE }, {
	[CurrentUserTypes.FETCH_USER_SUCCESS]: fetchUserSuccess,
	[CurrentUserTypes.FETCH_QUOTA_INFO_SUCCESS]: fetchQuotaInfoSuccess,
	[CurrentUserTypes.UPDATE_USER_SUCCESS]: updateUserSuccess,
	[CurrentUserTypes.SET_PENDING_STATE]: setPendingState,
	[CurrentUserTypes.SET_AVATAR_PENDING_STATE]: setAvatarPendingState,
	[CurrentUserTypes.REFRESH_AVATAR]: refreshAvatar,
	[CurrentUserTypes.SET_AS_INITIALISED]: setAsInitialised
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:currentUser.redux.ts

示例9: createReducer

		showStarred: false,
		selectedFilters: []
	}
};

const fetchMetadataSuccess = (state = INITIAL_STATE, { metadata}) => ({ ...state, metadata });

const setIsPending = (state = INITIAL_STATE, { isPending }) => ({ ...state, isPending });

const setActiveMeta = (state = INITIAL_STATE, { activeMeta }) => {
	const updatedState =  { ...state, activeMeta };
	if (!activeMeta) {
		updatedState.metadata = [];
	}
	return updatedState;
};

const setIsActive = (state = INITIAL_STATE, { isActive }) => ({ ...state, isActive });

const setComponentState = (state = INITIAL_STATE, { componentState = {} }) => {
	return { ...state, componentState: { ...state.componentState, ...componentState } };
};

export const reducer = createReducer(INITIAL_STATE, {
	[BimTypes.FETCH_METADATA_SUCCESS]: fetchMetadataSuccess,
	[BimTypes.SET_COMPONENT_STATE]: setComponentState,
	[BimTypes.SET_IS_PENDING]: setIsPending,
	[BimTypes.SET_IS_ACTIVE]: setIsActive,
	[BimTypes.SET_ACTIVE_META]: setActiveMeta
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:bim.redux.ts

示例10: createReducer

			{ order: 'asc', config: { field: 'label' } }
		);
	}
	return { ...state, settings };
};

const fetchMetaKeysSuccess = (state = INITIAL_STATE, { metaKeys }) => {
	return { ...state, metaKeys };
};

const fetchRevisionsSuccess = (state = INITIAL_STATE, { revisions }) => {
	return { ...state, revisions };
};

const fetchMapsSuccess = (state = INITIAL_STATE, { maps }) => {
	return { ...state, maps };
};

const updateSettingsSuccess = (state = INITIAL_STATE, { settings }) => {
	return { ...state, settings: { ...state.settings, ...settings} };
};

export const reducer = createReducer(INITIAL_STATE, {
	[ModelTypes.FETCH_META_KEYS_SUCCESS]: fetchMetaKeysSuccess,
	[ModelTypes.FETCH_SETTINGS_SUCCESS]: fetchSettingsSuccess,
	[ModelTypes.FETCH_REVISIONS_SUCCESS]: fetchRevisionsSuccess,
	[ModelTypes.SET_PENDING_STATE]: setPendingState,
	[ModelTypes.FETCH_MAPS_SUCCESS]: fetchMapsSuccess,
	[ModelTypes.UPDATE_SETTINGS_SUCCESS]: updateSettingsSuccess
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:model.redux.ts

示例11: setSortedNotifications

	const updatedNotifications = state.notifications.filter(({ _id }) => _id !== notification._id);

	return {...state, notifications: updatedNotifications };
};

export const patchNotification = (state = INITIAL_STATE, { notificationPatch }) => {
	const _id = notificationPatch._id;
	const updatedNotifications = state.notifications.map((notification) => {
		if (notification._id === _id) {
			return { ...notification, ...notificationPatch };
		}

		return notification;
	});

	return setSortedNotifications(state, updatedNotifications);
};

export const patchAllNotifications = (state = INITIAL_STATE, { notificationPatch }) => {
	return setSortedNotifications(state, state.notifications.map( (n) => ({ ...n, ...notificationPatch})));
};

export const reducer = createReducer(INITIAL_STATE, {
	[NotificationsTypes.SET_NOTIFICATIONS]: setNotifications,
	[NotificationsTypes.UPSERT_NOTIFICATION]: upsertNotification,
	[NotificationsTypes.DELETE_NOTIFICATION]: deleteNotification,
	[NotificationsTypes.PATCH_NOTIFICATION]: patchNotification,
	[NotificationsTypes.SET_DRAWER_PANEL_STATE] : setDrawerState,
	[NotificationsTypes.PATCH_ALL_NOTIFICATIONS] : patchAllNotifications
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:notifications.redux.ts

示例12: createReducer

	const modelIndex = foundProject.models.findIndex((model) => model.model === action.model);
	teamspaces[action.teamspace].projects[projectIndex].models[modelIndex].status = action.modelData.status;
	if (action.modelData.timestamp) {
		teamspaces[action.teamspace].projects[projectIndex].models[modelIndex].timestamp = action.modelData.timestamp;
	}
	return { ...state, teamspaces };
};

const setPendingState = (state = INITIAL_STATE, { pendingState }) => {
	return Object.assign({}, state, { isPending: pendingState });
};

const setComponentState = (state = INITIAL_STATE, { componentState = {} }) => {
	return { ...state, componentState: { ...state.componentState, ...componentState } };
};

export const reducer = createReducer({ ...INITIAL_STATE }, {
	[TeamspacesTypes.SET_TEAMSPACES]: setTeamspaces,
	[TeamspacesTypes.SET_MODEL_UPLOAD_STATUS]: setModelUploadStatus,
	[TeamspacesTypes.SET_PENDING_STATE]: setPendingState,
	[TeamspacesTypes.SET_COMPONENT_STATE]: setComponentState,
	// Projects
	[TeamspacesTypes.UPDATE_PROJECT_SUCCESS]: updateProjectSuccess,
	[TeamspacesTypes.CREATE_PROJECT_SUCCESS]: createProjectSuccess,
	[TeamspacesTypes.REMOVE_PROJECT_SUCCESS]: removeProjectSuccess,
	// Models
	[TeamspacesTypes.UPDATE_MODEL_SUCCESS]: updateModelSuccess,
	[TeamspacesTypes.CREATE_MODEL_SUCCESS]: createModelSuccess,
	[TeamspacesTypes.REMOVE_MODEL_SUCCESS]: removeModelSuccess
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:teamspaces.redux.ts

示例13: showDialog

		onConfirm: action.config.onSave,
		data: {
			disabled: action.config.disabled,
			sourceImage: action.config.sourceImage || ''
		},
		DialogProps: {
			fullScreen: true
		}
	};

	return showDialog(state, {config});
};

export const hideDialog = (state = INITIAL_STATE) => {
	return { ...state, isOpen: false, isPending: false };
};

export const setPendingState = (state = INITIAL_STATE, {isPending}) => {
	return { ...state, isPending };
};

export const reducer = createReducer({...INITIAL_STATE}, {
	[DialogTypes.HIDE_DIALOG]: hideDialog,
	[DialogTypes.SHOW_DIALOG]: showDialog,
	[DialogTypes.SHOW_ERROR_DIALOG]: showErrorDialog,
	[DialogTypes.SHOW_ENDPOINT_ERROR_DIALOG]: showEndpointErrorDialog,
	[DialogTypes.SHOW_CONFIRM_DIALOG]: showConfirmDialog,
	[DialogTypes.SET_PENDING_STATE]: setPendingState,
	[DialogTypes.SHOW_SCREENSHOT_DIALOG]: showScreenshotDialog
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:dialog.redux.ts

示例14: createActions

 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import { createActions, createReducer } from 'reduxsauce';

export const { Types: UsersTypes, Creators: UsersActions } = createActions({
	fetchUserDetails: ['teamspace', 'username'],
	setUserDetailsResponse: ['key', 'response']
}, { prefix: 'USERS/' });

export const INITIAL_STATE = {
	cachedResponses: {}
};

const setUserDetailsResponse = (state = INITIAL_STATE, {key, response}) => {
	const cachedResponses = { ...state.cachedResponses };
	cachedResponses[key] = response;
	return { ...state, cachedResponses };
};

export const reducer = createReducer(INITIAL_STATE, {
	[UsersTypes.SET_USER_DETAILS_RESPONSE]: setUserDetailsResponse
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:users.redux.ts

示例15: createReducer

	startListenOnSelections: [],
	stopListenOnSelections: [],
	clearSelectedNodes: [],
	getSelectedNodes: [],
	getSelectedNodesSuccess: ['selectedNodes'],
	showAllNodes: [],
	hideSelectedNodes: [],
	isolateSelectedNodes: []
}, { prefix: 'TREE/' });

export interface IObjectObjectState {
	selectedNodes: any;
}

export const INITIAL_STATE: IObjectObjectState = {
	selectedNodes: []
};

export const clearSelectedNodes = (state = INITIAL_STATE, {}) => {
	return { ...state, selectedNodes: [] };
};

export const getSelectedNodesSuccess = (state = INITIAL_STATE, { selectedNodes }) => {
	return { ...state, selectedNodes };
};

export const reducer = createReducer(INITIAL_STATE, {
	[TreeTypes.CLEAR_SELECTED_NODES]: clearSelectedNodes,
	[TreeTypes.GET_SELECTED_NODES_SUCCESS]: getSelectedNodesSuccess
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:tree.redux.ts


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