-
-
Notifications
You must be signed in to change notification settings - Fork 203
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 approval controller count state #306
Conversation
9de5b4d
to
2a49858
Compare
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.
LGTM
Why is the count needed in state? The count methods should already suffice I'd think. This introduces the possibility that it could get out-of-sync with the underlying list. |
[id]: info, | ||
}, | ||
[APPROVAL_COUNT_STORE_KEY]: this.state[APPROVAL_COUNT_STORE_KEY] + 1, |
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.
As an example of the count getting out of sync, this could happen here if id
is already in state. Then this would replace that entry, and falsely inflate the count by 1 per additional call.
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.
If consumers respect the interface of the controller and only use its public methods, it is impossible for that to happen (see _validateAddParams
).
I decided to add the approval count to the state of this controller in order to make it consumable via our usual state subscription logic.
#304 added the methods. This adds the state. Also properly initializes this controller, which wasn't happening previously. It's clearly not always necessary, but the constructor should always call
BaseController.initialize()
.