GithubHelp home page GithubHelp logo

anish000kumar / redux-box Goto Github PK

View Code? Open in Web Editor NEW
710.0 20.0 25.0 6.26 MB

Modular and easy-to-grasp redux based state management, with least boilerplate

License: MIT License

JavaScript 100.00%
react redux redux-saga

redux-box's People

Contributors

anish000kumar avatar binocarlos avatar dependabot[bot] avatar dragonfire1119 avatar nickbreaton avatar will-stone 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

redux-box's Issues

Reselect?

I'm new to all this stuff but found your (a) video on redux-box and really like the way it looks compared to all the boilerplate. I also found this project: react-boilerplate which seems great. I see lots of mention of using reselect for performance reasons, but can't say I actually understand what it is doing yet. I'm wondering if you could address the ability to use reselect for performance or if maybe redux-box addresses this in another way.

idea: replace screenshots with Markdown

I wonder why there are screenshots in Readme instead of text? It prevents e.g. copy-pasting (not to mention other aspects like overall accesibility, i.e. screen readers, poor connection, SEO etc.)

Markdown (at least in GH and NPM flavors) has syntax coloring out-of-the-box.
You write:
```javascript
import {createSagas, createCntainer } from 'redux-box'
```

And it looks:

import {createSagas, createCntainer } from 'redux-box'

https://guides.github.com/features/mastering-markdown/

extra sagas passed in via the config don't register

I'm using the sagas property of the config to pass in some additional sagas that are not part of a module and I'm noticing they are not registering - using this example from the docs

import { createStore } from 'redux-box'
import { call } from 'redux-saga/effects'
function* myCustomSaga() {
  console.log('my saga is registered')
}
const config = {
  sagas: [call(myCustomSaga)]
}
export default createStore(modules, config)

I'm not seeing myCustomSaga register.

I think this is because of this line:

config.sagas && config.sagas.forEach(saga => sagas.concat(saga));

which needs to be:

sagas = config.sagas ? sagas.concat(config.sagas) : sagas;

i.e. it looks as though the concatenated saga array is getting lost in a black hole within the forEach loop

I've tested this and it works - I will make a PR presently

Cannot read property 'sagas' of undefined

Hi,

After using this lines I got the error :

import store from "../store/index" // points to store/index.js file

const accessToken = store.getState().auth.accessToken;

console.log('accessToken', accessToken)

Possible to be a bug or my code mistaken ?

Thanks

Example with Testing

Thanks for this useful package and all the examples.

I couldn't find any example with a test. Specifically, I am interested in testing sagas. It seems the approach proposed in redux-saga (https://redux-saga.js.org/docs/advanced/Testing.html) is not applicable here or at least is not very straight forward. Appreciate if you provide a test case for sagas.

Thanks

More complex examples?

I like the example that you give in the Readme but when you open the example in the example folder its much simpler and doesnt seem to take advantage of that beautiful syntax you show in the readme.

It would be great if you could show a more complex example, perhaps one that does an api request too, to show how you handle async actions?

Improve Action creator

Pretty much how https://github.com/infinitered/reduxsauce does it.

Instead of creating a lot of functions that just return the object that represent the action that you are talking about,

You could use a function that does that for you and specially, it gives you back the action list.

take a look to reduxsaurce, I think it is worth to add something similiar or the same.

Side note,

that way you could even scope your actions based on some configuration when you create the actions, like prefix, which it is really handy when you have large applications (you do not need to hunt the entire code looking for every place that you need to rename (add the prefix) your action.

Store isn't passed to children with newer redux & react-redux versions

When using the newest versions of react-redux (^6.0.0) and redux (^4.0.1) instead of the versions this project uses (5.0.6 and ^3.7.2) the following exception occurs:
Either wrap the root component in a <Provider>, or explicitly pass β€œstore” as a prop to "Connect(MyComponent)
when using this setup (simplified):

import React from 'react';
import store from './store'
import { Provider } from 'react-redux';
import MyComponent from './MyComponent';

export default const App = () => (<Provider store={store}><MyComponent></Provider>);
import React, { Component } from "react";
import { module as testModule } from "./store/testModule";
import { connectStore } from "redux-box";
class MyComponent extends React.Component {
  render() {
    return (<div>Hey</div>)
   }
}
export default connectStore({
    test: testModule
})(MyComponent) 

I guess there has been a breaking change between the versions - it does work when using the lower versions in the project. Would be nice if someone more skilled than I am could take a look (and maybe update the dependencies?)

working with rn 0.56-0.57 / babel 7

Hello,
I'm using box on my < 0.56 and it's configured and working well but cannot setup it with new rn/babel.
As I read rn uses new metro-react-native-babel-preset

Any hint for setting it up ?
I think I cannot setup babel dependencies, I read that stages are deprecated in new babel!!!

Redux Saga effect 'select' doesn't work as expected

Redux Box packages things nicely into modules, where each module is nicely self-contained.

This goes as far as having Selectors that exist as part of the module, and when called are only give this modules portion of the state. This is fantastic for building up self-contained modules easily.

Unfortunately, Redux Box relies on the Redux Sagas "effects" for some feature. One such feature is the obtaining values from elsewhere in the state during a Saga - using the select effect.

This effect works exactly the same as in Redux Saga. Which means that it calls the provided selector with the entire state tree and not just the local modules portion of it. Ultimately this means that we need to have two different types of selector - some that work on the local module and some that work on the entire state tree.

It could be useful to have a variation of select that applies the selector only to the local module state, so that the selectors used can remain consistent.

Typescript?

This looks awesome! I really like it.

I would love to see a typescript example of this this in action because it seems like you should be able to strongly type this very nicely πŸ˜„

How to invoke actions from sagas

I'm trying to figure out how to invoke actions from sagas

Should this work ?

const state = {
	version: '1.0.0',
}

const actions = {
	setVersion: version => ({ type: 'SET_VERSION', payload: version }),
}

const mutations = {
	SET_VERSION: (state, action) => (state.name = action.payload),
}

const sagas = createSagas({
	GET_VERSION: function*(action) {
		const response = yield call(api.getVersion)
		yield put(actions.setVersion(response.version))
	},
})

But then what if I need to invoke an action from another module ?

Should I import the other module (or at least the other module's actions) ?

Any thoughts ?

P.D.: I've seen the saga example where you invoke put without the action creator ({type: ....}), but the idea of using the action creator is to have strong typing, whenever typescript becomes available.

Redux-box + GraphQL

I would like to get an example of how to use redux-box with an api GraphQl

Many thanks and beautiful work.

Include getters

like in vuex getters enable you write computed functions that return values that can be used across you app. this values are updated when state changes across your apps.

Support for dynamic selectors

I've noticed that the Selectors are all executed immediately and the results of them are provided to the React components for rendering. This means that it's difficult to have selectors that take parameters.

What I've taken to doing, which works but feels a bit strange, is having Selectors that return functions. For example:

    selectUsers: (state) => () => selectUsers(state),
    selectUserById: (state) => (id) => selectUserById(state, id)

So the React component sees two functions, one called selectUsers with zero parameter, and one called selectUserById with a single parameter. These can then be called as needed and will return the correct values from the state, but the actual execution of them is only on-demand and they can be parameterised.

I'm not sure if such a feature would be beneficial being included as a core part of redux-box, or how, but it would be useful for me :)

Adding Redux Observable?

I would love to see either an example of this with redux-observable (if possible) or have this added as a feature.

I love this syntax for modules, and think it paired with redux-observable would be really amazing.

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.