• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript reduxsauce.createReducer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: cloneDeep

	return { ...state, helicopterSpeed: speed };
};

const setIsFocusMode = (state = INITIAL_STATE, {isFocusMode}) => {
	return { ...state, isFocusMode };
};

const setClipEditSuccess = (state = INITIAL_STATE, {isClipEdit}) => {
	return { ...state, isClipEdit };
};

const setClipNumber = (state = INITIAL_STATE, {clipNumber}) => {
	return { ...state, clipNumber };
};

const setPanelVisibility = (state = INITIAL_STATE, {panelName, isVisible}) => {
	const visiblePanels = cloneDeep(state.visiblePanels);
	return { ...state, visiblePanels: {...visiblePanels, [panelName]: isVisible} };
};

export const reducer = createReducer(INITIAL_STATE, {
	[ViewerTypes.UPDATE_SETTINGS] : updateSettings,
	[ViewerTypes.SET_NAVIGATION_MODE_SUCCESS] : setNavigationModeSuccess,
	[ViewerTypes.SET_CLIPPING_MODE_SUCCESS] : setClippingModeSuccess,
	[ViewerTypes.SET_HELICOPTER_SPEED] : setHelicopterSpeed,
	[ViewerTypes.SET_IS_FOCUS_MODE] : setIsFocusMode,
	[ViewerTypes.SET_CLIP_EDIT_SUCCESS] : setClipEditSuccess,
	[ViewerTypes.SET_CLIP_NUMBER] : setClipNumber,
	[ViewerTypes.SET_PANEL_VISIBILITY] : setPanelVisibility
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:viewer.redux.ts


示例17: 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: StaticPagesTypes, Creators: StaticPagesActions } = createActions({
	loadTemplate: ['path'],
	setPendingState: ['isPending'],
	loadTemplateSuccess: ['path', 'template']
}, { prefix: 'STATIC_PAGES/' });

export const INITIAL_STATE = {
	templates: {},
	isPending: false
};

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

export const loadTemplateSuccess = (state = INITIAL_STATE, { path, template }) => ({
	...state,
	templates: Object.assign({}, state.templates, { [path]: template })
});

export const reducer = createReducer(INITIAL_STATE, {
	[StaticPagesTypes.SET_PENDING_STATE]: setPendingState,
	[StaticPagesTypes.LOAD_TEMPLATE_SUCCESS]: loadTemplateSuccess
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:staticPages.redux.ts


示例18: setLocalSessionStatus

export const loginFailure = (state = INITIAL_STATE) => {
	setLocalSessionStatus(state, { status: false });
	return { ...state, isAuthenticated: false };
};

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

export const setLocalSessionStatus = (state = INITIAL_STATE, { status }) => {
	window.localStorage.setItem('loggedIn', JSON.stringify(status));
	return state;
};

export const setAuthMessage = (state = INITIAL_STATE, { message }) => {
	return { ...state, message };
};

export const clearAuthMessage = (state = INITIAL_STATE) => {
	return { ...state, message: '' };
};

export const reducer = createReducer(INITIAL_STATE, {
	[AuthTypes.LOGIN_SUCCESS]: loginSuccess,
	[AuthTypes.LOGIN_FAILURE]: loginFailure,
	[AuthTypes.SET_PENDING_STATUS]: setPendingStatus,
	[AuthTypes.SET_LOCAL_SESSION_STATUS]: setLocalSessionStatus,
	[AuthTypes.SET_AUTH_MESSAGE]: setAuthMessage,
	[AuthTypes.CLEAR_AUTH_MESSAGE]: clearAuthMessage
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:auth.redux.ts


示例19: createReducer

	const newGroup = { ...state.componentState.newGroup };
	if (newGroup) {
		newGroup.willBeRemoved = true;
	}

	groupIds.forEach((groupId) => {
		groupsMap[groupId].willBeRemoved = true;
	});

	return { ...state, groupsMap, componentState: { ...state.componentState, newGroup } };
};

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

export const reducer = createReducer(INITIAL_STATE, {
	[GroupsTypes.FETCH_GROUPS_SUCCESS]: fetchGroupsSuccess,
	[GroupsTypes.TOGGLE_PENDING_STATE]: togglePendingState,
	[GroupsTypes.SET_COMPONENT_STATE]: setComponentState,
	[GroupsTypes.ADD_TO_HIGHLIGHTED]: addToHighlighted,
	[GroupsTypes.REMOVE_FROM_HIGHLIGHTED]: removeFromHighlighted,
	[GroupsTypes.ADD_TO_OVERRIDED]: addToOverrided,
	[GroupsTypes.REMOVE_FROM_OVERRIDED]: removeFromOverrided,
	[GroupsTypes.UPDATE_GROUP_SUCCESS]: updateGroupSuccess,
	[GroupsTypes.DELETE_GROUPS_SUCCESS]: deleteGroupsSuccess,
	[GroupsTypes.SET_CRITERIA_FIELD_STATE]: setCriteriaFieldState,
	[GroupsTypes.SHOW_UPDATE_INFO]: showUpdateInfo,
	[GroupsTypes.RESET_COMPONENT_STATE]: resetComponentState
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:groups.redux.ts


示例20: omit

	const starredMetaMap =  starredMeta.reduce((metaMap, tag) => {
		metaMap[tag] = true;
		return metaMap;
	}, {});

	return { ...state, starredMetaMap };
};

const addToStarredMetaSuccess = (state = INITIAL_STATE, { metaRecord }) => {
	return {
		...state,
		starredMetaMap: {
			...state.starredMetaMap,
			[metaRecord]: true
		}
	};
};

const removeFromStarredMetaSuccess = (state = INITIAL_STATE, { metaRecord }) => {
	return {
		...state,
		starredMetaMap: omit(state.starredMetaMap, metaRecord)
	};
};

export const reducer = createReducer(INITIAL_STATE, {
	[StarredMetaTypes.SET_STARRED_META]: setStarredMeta,
	[StarredMetaTypes.ADD_TO_STARRED_META_SUCCESS]: addToStarredMetaSuccess,
	[StarredMetaTypes.REMOVE_FROM_STARRED_META_SUCCESS]: removeFromStarredMetaSuccess
});
开发者ID:3drepo,项目名称:3drepo.io,代码行数:30,代码来源:starredMeta.redux.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript chai.assert类代码示例发布时间:2022-05-25
下一篇:
TypeScript reduxsauce.createActions函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap