redux-entity-helpers

0.0.7 • Public • Published

Redux Entity Helpers

Entity helpers for Redux

npm

🚧 This project is still in its early stages, you should expect things to break 🚧

Table of Contents

Getting Started

Installation

$ yarn add redux-entity-helpers

or

$ npm install --save redux-entity-helpers

You also need to install Redux Thunk.

Usage

🚧

Documentation

Introduction

Redux Entity State Shape

{
    allIds: Array<string>,
    byId: EntitiesById,
    isFetching: boolean
};

EntitiesById

Is a dictionary of entity organized by their id. The id must have a method toString().

API

🚧

Reducer Helpers

createEntityReducer(name, [options])

Creates the reducer that handles actions of an entity

name: string

The name of the entity (e.g. products)

options: ReducerOptions
  • mergeEntities: an optional function that handles merging of entities (Defaults to simple Object merging with spread operator).

Actions Helpers

fetchEntity(name, promise, [options])

Enables fetching entities

name: string

The name of the entity (e.g. products)

promise: Promise<EntitiesById>

A promise that should resolve to an EntitiesById object.

options
  • shouldMerge: a boolean value that tell whether or not the fetched entities should be merged with existing entities (defaults to false)
  • ids: an Array<ID> to be used when fetching entity with known ids.

Readme

Keywords

none

Package Sidebar

Install

npm i redux-entity-helpers

Weekly Downloads

1

Version

0.0.7

License

MIT

Last publish

Collaborators

  • federicobadini
  • macs91