-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Add guidelines for writing controllers #4110
Conversation
930bdba
to
3764164
Compare
docs/writing-controllers.md
Outdated
|
||
const fooController = new FooController(); | ||
|
||
const [activeAccounts, inactiveAccounts] = select( |
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'm not sure how we intend on using these selectors just for state access. I just made up this API, but not sure if reselect
or something else would work as well here.
I might drop this section, though, until we've worked out how selectors would work for this use case.
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.
It should probably be fooController.state
one line down from here, rather than fooController
. We'll need to select from the state. But aside from that, this looks basically like I had imagined as well!
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 ended up updating this example to use reselect
.
4412bf5
to
6ae1d55
Compare
So far we have not have any documentation on how to write controllers the BaseController v2 way. These guidelines aim to fill in the missing pieces. Note that while each guideline has examples, we are still missing a complete example controller file which demonstrates all of the guidelines in one go. That will come in a future PR.
6ae1d55
to
271cbd6
Compare
This is ready for review again. I've expanded heavily upon the set of guidelines I posted originally, so this may need a complete re-review. |
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.
Had some minor proofreading comments but looks great overall! Having a clear set of best practices available to reference should reduce a lot of friction and uncertainty around working with controllers.
Co-authored-by: Jongsun Suh <[email protected]>
Co-authored-by: Jongsun Suh <[email protected]>
Co-authored-by: Jongsun Suh <[email protected]>
…t a simple variable Co-authored-by: Jongsun Suh <[email protected]>
Co-authored-by: Jongsun Suh <[email protected]>
Co-authored-by: Jongsun Suh <[email protected]>
Co-authored-by: Jongsun Suh <[email protected]>
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.
Some suggestions for consistency with previous changes.
Co-authored-by: Jongsun Suh <[email protected]>
Co-authored-by: Jongsun Suh <[email protected]>
Explanation
So far we have not have any documentation on how to write controllers the BaseController v2 way. These guidelines aim to fill in the missing pieces. Note that while each guideline has examples, we are still missing a complete example controller file which demonstrates all of the guidelines in one go. That will come in a future PR.
References
Progresses #4504.
Changelog
(None)
Checklist