-
Notifications
You must be signed in to change notification settings - Fork 31
Setup tooling and add docs #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Trying to review this during the week. Will update you. 👌 |
julienben
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few small comments but overall this looks great.
If I have only thing to say, it would be that I'm not 100% clear on the README. I wish it did a better job of explaining to potential new users what this is for.
README.md
Outdated
| ) | ||
| ``` | ||
|
|
||
| Note the `createInjectorsEnhancer` function takes two options. `createReducer` should be a function that when called will create the root reducer. It's passed the injected reducers as an object of key-reducer pairs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"will create the root reducer" => Might want to write "will return the root reducer", no?
README.md
Outdated
| } | ||
| ``` | ||
|
|
||
| `runSaga` should ussually be `sagaMiddleware.run`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*usually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ussually should be replaced in a few places.
README.md
Outdated
|
|
||
| ## Motivation | ||
| There's a few reasons why you might not want to load all your reducers and sagas upfront: | ||
| 1. You don't need all the reducers and sagas for every page. This library let's you only load the reducers/sagas that are needed for the page being viewed. This speeds up the page load time because you can take advantage of [code-splitting](https://webpack.js.org/guides/code-splitting/). This is also good for performance after the page has loaded, because less reducers and sagas are running. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling:
- This library lets you load
- Less reducers => Fewer reducers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Similar let's => lets errors in other places)
src/checkStore.js
Outdated
|
|
||
| /** | ||
| * Validate the shape of redux store | ||
| * Validates the redux store is setup properly to work with this library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setup => set up (it's used as a verb here, not a noun)
|
I implemented all of the requested changes. I'm not exactly sure how to improve the README. I tried re-wording the beginning a bit but if that's not clear enough I might need help. Also, I need help enabling travis to work on this repo. I think someone needs to go into travis settings and enable it. |
|
ah you're probably right. We can do that after it gets into master. |
|
@julienben Is this PR good to go or is there anything else I should change? |
julienben
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few additional thoughts. Will continue reviewing later.
README.md
Outdated
| @@ -1,2 +1,81 @@ | |||
| # injectors | |||
| Asynchronous injectors for Redux reducers and sagas. As used by react-boilerplate. | |||
| Dynamically load [redux](https://redux.js.org/) reducers and [redux-saga](https://redux-saga.js.org/) sagas as needed, instead of loading all of them upfront. See [motivation](#Motivation). As used by react-boilerplate. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe link to react-boilerplate's repo in "as used by rbp"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also consider adding a line re:motivation instead of having everything at the bottom.
| ``` | ||
|
|
||
| ### Setting up the redux store | ||
| The redux store needs to be configured to allow this library to work. The library exports a store enhancer that can be passed to the `createStore` function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's where the explanation could be clearer IMO. Instead of simply "the store needs to be configured for the library to work", something more explicit like:
We take advantage of the redux store being a simple POJO to add to it several keys:
injectedReducers: A registry of all the reducers injected into the app to ensure we don't overwrite an existing reducer.- injectedSagas: Same thing but for sagas. Also makes sure we don't run the same saga twice for one action.
- runSaga: Just like redux provides
store.replaceReducer, we need to addstore.runSagato enable the dynamic injection mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's kind of getting into implementation details. Do we need to explain that in the "Setting up the redux store" section? It's meant to be a quick start so I kind of wanted to be brief.
I understand it's helpful to explain this so developers don't think it's magic, but I wonder if this could go in a different section? i.e. "How does it work?"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
README.md
Outdated
|
|
||
| const store = createStore( | ||
| createReducer(), | ||
| undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not write initialState here?
julienben
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks excellent!
docs/api.md
Outdated
|
|
||
| const store = createStore( | ||
| createReducer(), | ||
| undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialState would be nice here too.
| import { createInjectorsEnhancer } from "injectors" | ||
|
|
||
| function createReducer(injectedReducers = {}) { | ||
| const rootReducer = combineReducers({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is off in some of your code samples. 0 => 1 space => 3 spaces
docs/api.md
Outdated
|
|
||
| #### Parameters | ||
|
|
||
| - `options` **[Object][24]** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to call this "options" given that they're not actually optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or is that just a standard pattern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-named to params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe do it everywhere that function params are not optional? There's a few more instances apparently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I forgot to re-build the docs, I'll fix that after work
|
(Btw, those were my final comments. Let's merge asap, do anything else that needs to be done before publishing - like picking a name!, and then PR to react-boilerplate.) |

I think this is all that's left :)
In this PR:
jsx-a11ysince we don't render any dom elements