-
Notifications
You must be signed in to change notification settings - Fork 178
[github] Use attributes as another way to provide metadata #670
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
[github] Use attributes as another way to provide metadata #670
Conversation
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.
Hi Dmitry, thanks for working on this!
This largely works (see my one comment though).
The reason I didn't want to go that route is that it would be a better architecture if parseURL()
just parses the URL like the function name implies, returns its components, and we override them as needed in the constructor. However, a big problem with that approach is that certain components depend on others, e.g. apiCall, path.
I'm not sure if the implementation simplicity is worth the architectural tradeoff.
Hi Lea! Thank you for the comments. I agree with your thoughts and share them.
Of course, it doesn't. Well, I continue working then. :) |
Btw, I did mean I wasn't sure. If anything, I was leaning towards that the tradeoff might be worth it. But if you want to look into it a bit more first, that's fine! |
Yes, I'd like to look into it a bit more. Every single time I learn a lot from these iterations. And I appreciate that. Thank you. |
…s the URL) and take into account cross dependencies between metadata
Hi @LeaVerou, Will you please give this PR another look when you have time? I made some adjustments and would love to have feedback from you. Thanks! |
Thank you for working on this Dmitry. I will review properly in a bit. Object.defineProperty(ret, "apiCall", {
get () {
return /* expression */
},
set (v) {
delete this.apiCall;
this.apiCall = v;
},
configurable: true,
enumerable: true
}); |
I saw a similar code in the Mavo code base, but, honestly, I’ve never used it myself. It’s not in my blood. Yet. :) Thank you for your suggestion (question). I’ll examine this object method on MDN (or elsewhere) and give it a try. I will be back soon. ;) |
Credit to Lea Verou for her idea and the brilliant following blog post that helped me a lot
@LeaVerou Thank you so much for your suggestion and the brilliant following blog post that helped me A LOT. If I got everything correctly, the code we have now is more maintainable, DRY, and without any doubt, more professional. 🤞🏻 The last word is up to you, of course. Your help is priceless. I appreciate that. Thank you! 🙇 |
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. Nice work, Dmitry.
I think we should move the writable getters to a helper in util.js
(or even one in Bliss), but we can do that via a separate PR later.
Next step would be to add some tests for this, both for specifying params via attributes that aren't present in the URL, as well as overriding params that are present.
Thank you, Lea!
Yes, it's on my radar.
Vote for Bliss. :) Would love to contribute to that awesome project too. |
Then hold off for a bit longer, I'm rewriting bliss to use ESM so until that ships, no new features. |
Deal! 🤝 |
Let's try to fix #665 (or at least begin iterating over it that I find beneficial). 😀