-
Notifications
You must be signed in to change notification settings - Fork 21
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
[chore] ♻️ Refactor onConnect listener creation to a util function #19
Conversation
/snapit |
🫰✨ Thanks @QuintonC! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/[email protected] yarn add @shopify/[email protected] |
You can test this PR using this CodeSandbox |
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.
Great cleanup, thanks! I tophatted only on MetaMask Desktop
|
||
return unsubscribeToOnConnectListener; | ||
return dispatch(listener); | ||
}, [dispatch, onConnect, requireSignature]); |
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.
is requireSignature
still a dependency?
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.
is
requireSignature
still a dependency?
Nope! Good eye. That also removes some other lines from the hook. Thanks!
b6ad1ca
to
2068be3
Compare
What is the context for these changes?
Refactors and simplifies the
onConnect
listener logic. This allows for easier middleware creation foronConnect
events by removing the possibility to missed actions (if the actions foronConnect
logic are to ever change) and DRYs up the creation of listeners.The inspiration behind this was not only to DRY up the code a bit, but also because in #4 I am going to re-use this logic (it could likely be reused in #13 as well) for looking up ENS names when a wallet connects.
Note: I was going to add tests for
useMiddleware.ts
as well, however I noticed that we need to create some form of app context in order to render hooks with the state provider. I'd prefer for that to be done the right way, and I believe that doing so will make this PR larger than it should be.How can this be tophatted?
Primarily green CI (I've added tests for the functionality). However, I will also run
/snapit
and link a CodeSandbox with the snapshot version for testing.Test CodeSandbox
🎩 Checklist
Tested for accessibilityN/AUpdated relevant documentation for the changes (if necessary)N/A