Skip to content

Conversation

@BenLorantfy
Copy link
Collaborator

@BenLorantfy BenLorantfy commented Aug 29, 2019

I think this is all that's left :)

In this PR:

  • Setup bili for cjs and es builds
    • Not sure if I also need umd or if cjs and es is enough
  • Setup prettier
  • Setup eslint
    • Copied linting rules from rbp
    • Disabled a few rules that would cause a different style than rbp. I think this is because I installed the latest airbnb preset, rbp might be on an earlier one.
    • Removed jsx-a11y since we don't render any dom elements
  • Setup lint-staged
  • Created travis file
    • Need help enabling travis for this repo though
  • Add "prepublishOnly" script that runs the tests and build before publish
  • Add "files" array to package.json
  • Add docs

@BenLorantfy BenLorantfy changed the title Please do not review yet Setup tooling and add docs Sep 1, 2019
@BenLorantfy BenLorantfy marked this pull request as ready for review September 1, 2019 20:48
@julienben
Copy link
Member

Trying to review this during the week. Will update you. 👌

Copy link
Member

@julienben julienben left a 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.
Copy link
Member

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`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*usually

Copy link
Member

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.
Copy link
Member

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

Copy link
Member

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)


/**
* Validate the shape of redux store
* Validates the redux store is setup properly to work with this library.
Copy link
Member

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)

@BenLorantfy
Copy link
Collaborator Author

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.

@julienben
Copy link
Member

image

This is what Travis tells me when I try to enable it for this repo. I'm assuming this means we need a travis file and some tests in the master branch before it can be enabled?

@BenLorantfy
Copy link
Collaborator Author

ah you're probably right. We can do that after it gets into master.

@BenLorantfy
Copy link
Collaborator Author

@julienben Is this PR good to go or is there anything else I should change?

Copy link
Member

@julienben julienben left a 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.
Copy link
Member

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"?

Copy link
Member

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.
Copy link
Member

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 add store.runSaga to enable the dynamic injection mechanism.

Copy link
Collaborator Author

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?"

Copy link
Member

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,
Copy link
Member

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?

Copy link
Member

@julienben julienben left a 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,
Copy link
Member

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({
Copy link
Member

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]**
Copy link
Member

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?

Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-named to params

Copy link
Member

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.

Copy link
Collaborator Author

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

@julienben
Copy link
Member

(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.)

@BenLorantfy BenLorantfy merged commit 3223506 into dev Sep 16, 2019
@julienben julienben deleted the setup-processes branch September 25, 2019 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants