1.0.1 • Published 6 years ago

@salsita/react-crud v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

react-crud

Install

Install this package with npm

npm i @salsita/react-crud

or yarn

yarn add @salsita/react-crud

API

Modules

Constants

Functions

CrudActions

CrudActions.entitiesFetched(route, key, result) ⇒ Action

Saves result of normalized data for a route

Kind: static method of CrudActions

ParamTypeDescription
routestringRoute name
keystringKey of entity
resultnumber | Array.<number>ID or IDs of entities (the result of normalization)

withRouterParams ⇒ function

Creates a composed effectParamsFactory which automatically passes current route params to effectParamsFactory

Kind: global constant
Returns: function - Composed effectParamsFactory

ParamTypeDescription
effectParamsFactoryfunctionto be wrapped

crudReducer(state, action) ⇒ CrudState

The reducer of the crud module

Kind: global function

ParamTypeDescription
stateCrudStateThe state of the crud module
actionActionA redux action

saveEntity(entityData, entity, mapEntityToSaveParams, form) ⇒ Object

Creates or updates entity from form data

After entity has been saved, it reflects the data back into entity repository.

Kind: global function
Returns: Object - updated entity

ParamTypeDescription
entityDataObjectEntity data
entitystringEntity type
mapEntityToSaveParamsfunctionA function that maps an entity to the save params
formstringId of the form

crudSaga(mapRouteToFetchParams)

This saga has to be forked in the root saga of the app

Kind: global function

ParamTypeDescription
mapRouteToFetchParamsfunctionA function that maps a route to the fetch params