@salsita/react-crud

1.0.1 • Public • Published

react-crud

Install

Install this package with npm

npm i @salsita/react-crud

or yarn

yarn add @salsita/react-crud

API

Modules

CrudActions

Constants

withRouterParamsfunction

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

Functions

crudReducer(state, action)CrudState

The reducer of the crud module

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.

crudSaga(mapRouteToFetchParams)

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

CrudActions

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

Saves result of normalized data for a route

Kind: static method of CrudActions

Param Type Description
route string Route name
key string Key of entity
result number | 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

Param Type Description
effectParamsFactory function to be wrapped

crudReducer(state, action) ⇒ CrudState

The reducer of the crud module

Kind: global function

Param Type Description
state CrudState The state of the crud module
action Action A 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

Param Type Description
entityData Object Entity data
entity string Entity type
mapEntityToSaveParams function A function that maps an entity to the save params
[form] string Id of the form

crudSaga(mapRouteToFetchParams)

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

Kind: global function

Param Type Description
mapRouteToFetchParams function A function that maps a route to the fetch params

Readme

Keywords

none

Package Sidebar

Install

npm i @salsita/react-crud

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

15.6 kB

Total Files

8

Last publish

Collaborators