redux-plus's People
redux-plus's Issues
dispatchEnhancer should add meta as 3rd parameter
helpers/api should support multiple calls
Dynamic selector not working
Investigate this (see TODO comment):
import {
createStore, combineReducers, createReducer, createSelector,
applyMiddleware, compose, plus,
} from 'redux-plus'
import api from './api'
import toTrees, {getMaxDepth, getNodes} from './toTrees'
const reducer = combineReducers({
categories: createReducer({
GET_DATA: api('GET', '/categories'),
GET_DATA_SUCCESS: (state, {payload: categories}) => categories,
}, []),
overview: createReducer({
SELECT: (state, {payload: _id}) => {
const index = state.selected.findIndex(id => id === _id)
let selected
if (index === -1) selected = state.selected.concat(_id)
else selected = state.selected.slice(0, index + 1)
return {...state, selected}
},
CLEAR_SELECTION: (state) => ({...state, selected: []})
}, {selected: [], sortBy: 'allocation'}),
detailID: createReducer({
SET_DETAIL_VIEW: (state, {payload: id}) => id,
CLEAR_DETAIL_VIEW: () => '',
SELECT: () => '',
CLEAR_SELECTION: () => '',
}, ''),
detail: createSelector(
'detailID',
'overview.selected', // TODO (redux-plus): investigate why dynamic selector doesn't work here
'dataTree.id',
'treeStats.nodes',
(state, id1, selected, id3, nodes) => {
console.log('1', id1, '2', selected.length, '3', id3)
const id = id1 || selected.slice(-1)[0] || id3
if (!nodes || !id) return null
return nodes.find(node => id === node.id)
}
),
dataTree: createSelector(
'categories',
'overview.sortBy',
(state, categories, sortBy) =>
toTrees(categories, sortBy, ['desc'])[0]
),
treeStats: createSelector(
'dataTree',
(state, dataTree) => ({
maxDepth: !dataTree ? 0 : getMaxDepth(dataTree),
leafNodes: !dataTree ? [] : getNodes(dataTree, ({children}) => !children.length),
nodes: !dataTree ? [] : getNodes(dataTree),
})
)
})
const logger = applyMiddleware(store => next => action => {
const result = next(action)
console.log(action, store.getState().detail)
return result
})
export const store = createStore(reducer, compose(plus, logger))
export default store
Better error messages needed
selector should run `getModel` on inputs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.