0.1.4 • Published 4 years ago

redux-simple-selectors v0.1.4

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Redux Simple Events

npm version

redux-simple-selectors aims to make the selectors generation as easy as possible.

You can just take the initial state of your Redux application and generate selectors out of it.

It gives the predictable and readable mapping with reselect features and equals function from Ramda.

Getting started

Install

$ npm install redux-simple-selectors

or

$ yarn add redux-simple-selectors

Usage Example

Suppose we have a typical Redux reducers with initialState.

const initialState = {
  todoData: {
    nestedData: ""
  },
  loading: true
}

function todoAppReducer(state = initialState, action) {
// ...

One can just generate selectors out of initialState

import {fillSimpleSelectors} from 'redux-simple-selectors'

export const todoAppStoreRouting = {
  ...fillSimpleSelectors(initialState, CONFIGS_REDUCER_ROOT)
}

And then use it in the application:

import {useSelector} from 'react-redux'
import {todoAppStoreRouting} from '../store/todoAppStore'
///...
const configMetadatas = useSelector(configsStoreRouting.nestedData.selector)

E.g. for next initialState:

const initialState = {
  todoData: {
    nestedData: ""
  },
  loading: true
}

There will be next selectors generated:

configsStoreRouting.todoData
configsStoreRouting.todoData.nestedData
configsStoreRouting.loading
0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago