-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
adds utility.js as facade to generic javascript utility functions #7738
adds utility.js as facade to generic javascript utility functions #7738
Conversation
Annnd had to rework things a bit, the first way I'd added utility.js didn't play nice with Karma, so tests were failing. Not sure why, but the Instead, I'm now bundling the utility file into the umbraco.services module. Tests all pass, umb utility object is available everywhere. It doesn't feel like the best solution, am open to other ways. |
Hi @nathanwoulfe I don't think it needs to be named anything in relation to Umbraco, so I would say we could get rid of the "umb". Any thoughts, ideas to elaborate on? |
@nielslyngsoe I jumped between Maybe |
@nathanwoulfe if you like it, I think we can go with it 😀. Then we can always be enlightened later if someone has a great name. 🌟 |
Descriptive naming is good naming. I'll update the PR in the morning. |
Cool, and just let me know if you need anything or have some thoughts you like some perspectives to 😊 then I'm right here. |
… Updated umb.noop examples to Utility.noop
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 @nathanwoulfe,
Great work here 👍
I added a few notes for your changes. Generally it seems that we can't just replace the functions from Angular with similar functions from Underscore, as they differ in their implementations.
Most likely this only affects edge cases, but I believe this is something we should test before making the switch. Not being a frontender, I don't really know how to do this the best way though 🤷
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.
@nathanwoulfe thanks for the last changes. I think it looks good now, as the functions have been abstracted away in the new Utilities
variable, but still with the same implementation 😄
I had a quick search through Umbraco's source code, and angular.extend
seems to be used a number of times. Could you add a new function for that as well?
https://github.com/umbraco/Umbraco-CMS/search?p=1&q=angular.extend&unscoped_q=angular.extend
Umbraco also uses angular.forEach
a lot, but I'd imagine this can be replaced by Array.prototype.forEach
instead, so no need to add an additional function for that.
@abjerner, yeah, had assume Had intended using |
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.
@nathanwoulfe awesome - I'm happy to approve this 👍
Hey @nathanwoulfe - great start! Sorry for the delay but world events kind of interfered 🙈 Thanks again!! 👍 ⭐️ |
@nul800sebastiaan these are strange times indeed... Having this merged means the other related tasks can now be tackled 👍 |
Prerequisites
This is the first step required for the AngularJs divorce proceedings...
Description
Changes here introduce
utility.js
to either replace AngularJs ng-function stuff, or to provide a facade to underscore functions (which in turn replace AngularJs ng-function stuff). Ideally at some point in the future the underscore dependency can be removed too, but for now it's required to manage some of the more complex bits.Functions from AngularJs' ng-functions not included here are either not used in the current codebase, or can be replaced with vanilla JS (things like angular.forEach, for example).
Open to changing the naming, but felt
umb
was an appropriate namespacing, particularly asUmbraco
is already used to provide access to the server variables collection. I guess we could attach methods to that object, but that might prove confusing.Given all that, this change doesn't actually do anything, just adds a collection of new methods. Can verify these are available globally by bashing
umb
into the browser console, to return the object and its contained methods. Can even test the methods if you're so inclined, most are obvious in their intent.