Coder Social home page Coder Social logo

redux-duck's People

Contributors

sergiodxa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

redux-duck's Issues

Proposal: createReducer should throw error if an action type is undefined

Scenario

I was re-using an action type from another duck, and a weird bug stuck me:

// duck-a.js
import { SOME_ACTION_TYPE } from './duck-b'
// ... some other stuff ...
createReducer({
  [SOME_ACTION_TYPE]: (state, action) => console.log('Reducer in A') || state;
});
// duck-b.js
const duck = createDuck('b');
// ... some other stuff ...
export const SOME_ACTION_TYPE = duck.defineType('SOME_ACTION_TYPE');
export const someAction = duck.createAction(SOME_ACTION_TYPE)
createReducer({
  [SOME_ACTION_TYPE]: (state, action) => console.log('Reducer in B') || state
});

When I dispatch someAction, the reducer in B is invoked, but not the reducer in A.

After spending hours I found that I was importing something from duck-a to duck-b as well, causing a circular dependency between duck-a and duck-b, which makes the imported SOME_ACTION_TYPE becomes undefined.

Proposal

Although the circular dependency is entirely my fault, I think createReducer can help me spot the circular dependency if createReducer can throw error when undefined is one of the object key.

Add support for FSA error and meta fields

There is currently no way to set FSA error and meta fields.
Maybe the actionType functions could have another optional argument with the information.

actionType(errorPayload, { error: true });
actionType(payload, { meta: { foo: 123 } });

This is of course a bit tricky when there is no payload but perhaps it is not too much of a problem

actionType(undefined, { error: true });
actionType(undefined, { meta: { foo: 123 } });

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.