iceddev / cooldux Goto Github PK
View Code? Open in Web Editor NEWSimple ducks pattern helper for redux
Simple ducks pattern helper for redux
We often make an action such as fetchIfNeeded()
that checks the state first.
We could have the cooldux middleware do that if our actions were wrapped in a checkCache()
type of function or potentially if cooldux options had a checkCache flag
since we're never referencing it directly in a single duck, make it easier and increment a counter or something.
this can make it more difficult to debug if you're counting on action names, but yo: devtools, breakpoints, console.log etc.
Instead of import { resetReducer } from cooldux
:
export const { someAction, someOtherAction, initialStateCombined } = duck;
const reducer = resetReducer(initialStateCombined, (state = initialStateCombined, action) => {
return duck.reducerCombined(state, action);
});
export default reducer;
It should be as simple as:
export const { someAction, someOtherAction } = duck;
export default duck.resetReducer;
you can still the former example if you need custom reducer functionality. Just finding myself using the same reset pattern too often
Documentation could probably be improved in the following areas:
More of a discussion than a bug but:
https://github.com/iceddev/cooldux/blob/master/index.js#L46
Here promiseHandler ends up gobbling up errors. Which means if I have a create method using it inside of a react component like so:
createMethod(someData)
.then((success) => {
this.setState({
msg: 'thing successfully created'
})
})
It will always say thing was created. I'd prefer to explicitly handle the error myself by rethrowing it rather than just returning null, however I can see why some people might prefer the existing implementation.
How do you feel about throwing here vs returning the null?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.