Coder Social home page Coder Social logo

lukasz-pluszczewski / reduxbreeze Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 1.79 MB

Powerful redux wrapper to make handling redux actions and reducers a breeze!

License: MIT License

JavaScript 99.73% HTML 0.26% CSS 0.02%
redux actioncreator reducer reducers flux state state-management

reduxbreeze's Introduction

redux-breeze

Powerful redux wrapper to make handling redux actions and reducers a breeze!

CircleCI

Library to make managing state, actionCreators, reducers in your redux application a breeze. You can finally stop copyPasting and start actually coding! :)

Note: This library is designed to help experienced developers in complex apps. If you are new to redux you definately should first learn how to use it, and when you get familiar with it and get bored by copying a lot of code, you can return to reduxBreeze ;)

Note2: This library is in early stage of development. Use at you own risk and, if you like the idea, feel free to help me making it epic! ;)

FAQ

Why this exists?

Redux is really great! It allows you to have whole application state in one, easily accessible place and manage it in a predictable way. All is good... until your application gets big and you write tens or even hundreds of same reducer cases and action creators. You start thinking: "that's a lot of work a computer is perfect at: copying stuff around" Exactly!

Are there good alternatives?

Let me know if you find one.

I found a bug! What should I do?

There are at least 3 options:

  1. Add an issue, write test(s) for bug you found, write fix that will make your test(s) pass, submit pull request
  2. Add an issue, write test(s) for bug you found, submit pull request with you test(s)
  3. Add an issue

All contributions are appreciated!

Documentation

Ok, so what do I get?

Let's imagine you created forms. A lot of forms. And you wanted to keep values in redux state.

Most likely you have a lot of similar code in your app

export default function formReducer(state = initialState.form, action) {
  switch (action.type) {
    case CHANGE_FULL_NAME:
      return {
        ...state,
        fullName: action.payload,
      };
    default:
      return state;
}

export function changeFullName(fullName) {
  return {
    type: CHANGE_FULL_NAME,
    payload: fullName,
  };
}

What if I tell you that you can avoid writing these action creators and reducers? And, no, not by creating one CHANGE_FORM_FIELD action. ;) You can actually avoid writing even the single reducer or a single action creator!

Only define something like:

changeFullName: {
  type: 'default',
  result: {
    fullName: 'payload',
  },
}

And that's all! No action creators written. No reducer cases! You want default values? Or maybe custom initial value?

changeFullName: {
  type: 'default',
  result: {
    fullName: { source: 'payload', default: 'John Doe', initial: 'No full name here yet' },
  },
}

And then use it like this:

this.props.changeFullName('John Smith');

...

connect(
  null,
  {
    changeFullName: reduxBreezeInstance.getAction('changeFullName'),
  }
)(MyFancyComponent);

"Huh, that's very simple example" you say. That is. But reduxBreeze is infinitely extensible! If you haven't found plugin that fits your use case (like using custom redux middleware and strangely managing side-effects) you can write your own in no-time. It's like writing your actionCreator, reducer and initialState ONCE. Once and for all!

Interested? Dive into the documentation :)

Plugins

I wanna help!

Great!

All pull requests are appreciated as long as the code is well tested, documented and linted ;)

You may grab a thing from todo (see below) or write plugins for your use-case.

Todo

  • write action definitions validation (by default only checking for 'type' field, but make it plugin enabled)
  • add more plugins:
    • redux-saga
    • redux-thunk
  • add selectors functionality (plugin-enabled)

reduxbreeze's People

Contributors

lukasz-pluszczewski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

reduxbreeze's Issues

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.