Skip to content

Conversation

@binh-dam-ibigroup
Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup commented Oct 2, 2020

This PR extracts the code to parse middleware configuration vars,
and inlines methods previously in utils/middleware, as brought up by #224 (comment) and #224 (comment).

@binh-dam-ibigroup binh-dam-ibigroup added WIP Work in progress and removed WIP Work in progress labels Oct 2, 2020
* - apiKey and apiBaseUrl from state.otp.config.persistence.otp_middleware,
* - accessToken and loggedIUnUser from state.user.
* - checks that otp_middleware is set, and throws an error if not.
* @param functionToExecute the code to execute, with parameters (dispatch, arguments)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please note that functionToExecute can be a function that can be awaited upon.

Copy link
Contributor

@evansiroky evansiroky left a comment

Choose a reason for hiding this comment

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

Just one comment about a comment

Copy link
Member

@landonreed landonreed left a comment

Choose a reason for hiding this comment

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

This approach is far too clever. I really disagree with how the executeWithMiddleware method body is structured and how it is invoked throughout user.js.

@landonreed landonreed removed their assignment Oct 5, 2020
@binh-dam-ibigroup
Copy link
Collaborator Author

This approach is far too clever. I really disagree with how the executeWithMiddleware method body is structured and how it is invoked throughout user.js.

It highlights the core logic for these actions and hides repeat code to extract and check common variables.

Copy link
Contributor

@evansiroky evansiroky left a comment

Choose a reason for hiding this comment

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

I'm going to have to change my review to request changes. I kind of agree with Landon in that this introduces a bit too much abstraction/overhead. I think the executeWithMiddleware shouldn't exist and instead it should simply be a util function that makes sure the middleware config exists and if so returns the desired middleware data given the getState method.

@binh-dam-ibigroup binh-dam-ibigroup changed the base branch from dev to phone-verification October 15, 2020 14:16
@binh-dam-ibigroup binh-dam-ibigroup merged commit 65d708c into phone-verification Oct 15, 2020
@binh-dam-ibigroup binh-dam-ibigroup mentioned this pull request Oct 30, 2020
@landonreed
Copy link
Member

🎉 This PR is included in version 1.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@binh-dam-ibigroup binh-dam-ibigroup deleted the refactor-user-actions branch December 18, 2023 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants