0.0.7 • Published 7 years ago

redux-entity-helpers v0.0.7

Weekly downloads
18
License
MIT
Repository
github
Last release
7 years ago

Redux Entity Helpers

Entity helpers for Redux

npm

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

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

:construction:

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

:construction:

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.
0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago