Extending Peregrine Talons for Custom Applications #4234
MichaelHeinzman
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background
I'm currently working on a website that utilizes magento peregrine talons in AEM ui.frontend. We have a mix of custom code where we took the talons outlined in pwa studio and made them our own. However, this got us in trouble when we needed to upgrade peregrine and certain features of our application. We had to go line by line and check if we needed to change the customized components to align more with the updated components. It took a while and we still have scattered customized components across our application.
Going line by line isn't a long-term solution to updating magento peregrine talons. I would rather know exactly what functions and variables we customized, and have it be in one file, not mixed with the magento peregrine code. This was why I thought about wrapping the talon in a hook, changing only the values and functions we needed to change, so that I can see clearly the customized code. However, I can't do this approach since not all of the values in the talon used are returned. I could repeat declarations but that would defeat the point of the wrapper.
What I am wondering
Can an update to the talons be made where they return all of the values in the talon.
For example, right now I'm trying to create hook called useSignIn.js that extends the useSignIn talon from peregrine. Since we use a different handleSubmit I was going to return our custom handleSubmit that we set in the wrapper using the values from the peregrine talon.
But, there are certain mutations and values that I can't access such as the signIn mutation, since it's not returned.
I'm forced to copy all of the code from the useSignIn talon, make a new file and customize that file. This implementation has already failed us when we upgraded @magento/peregrine and different packages, which led to half of our site breaking.
If we could wrap the package instead of creating a new file with a customized copy, then we can pick and choose what we want customized, it would be immutable, and when we upgrade in the future it would limit the damages. We would also be able to see exactly what has changed without having to worry about if we customized too much.
Example Extended / Customized useSignIn.js hook
Here's my implementation:
As of right now, the only returned values from the useSignIn talon are
Of course I'm not just talking about the useSignIn hook, this would be useful for customization of all of the talons.
Example peregrine useSignIn.js talon update.
Here is an example of changes I propose to make to the useSignIn.js talon in peregrine library, that would allow it to be wrappable.
Beta Was this translation helpful? Give feedback.
All reactions