This week we have so much news around new exciting RFCs for you that it was hard for us to even keep up! But we still tried our best to give you a good summary of what cool features might be landing in your favorite framework in the future.
We also have shining news for your favorite dev tool - the Ember Inspector - and another fresh Readers’ Question about easy module imports for you this week. 🐹
Ember comes with a great deal of tools to get a job done right out of the box. Most of the time you don’t have to look too far, like the tools on your tool belt, to find the right function or helper that comes as part of the framework. However, like most things in life, these tools need improvements or upgrades to match the ever-changing day-to-day challenges. This week’s RFCs (Request for Comments) aim to add or enhance some of your most used tools.
Array functions: All things Ember.A() without the Ember.A(). Ember makes working with arrays a breeze. mapBy, rejectBy, pushObject, uniq, the list goes on. These helpful Array methods make for a good developer experience, but they do come at a cost. If Array prototype extensions are disabled (as is the case in FastBoot) it becomes frustrating to defensively wrap every Array in Ember.A(). Additionally, these methods are wastefully added to the global Array prototype when only a handful of them are ever used. RFC#323 proposes that all Array methods are extracted and exported as similarly named functions. For example, instead of using Array.mapBy(prop), you would use the mirrored function mapBy(array, prop).
On the surface the drawbacks to such an approach would be an increase in Ember’s framework size, but since the conversion is nearly one-to-one, the increase should be negligible.
Array helper: @mmun has finished up the RFC for an array template helper. This RFC proposes a new template helper for dynamically creating Arrays in templates. The usage is similar to the hash template helper and helps fill in a hole in the Ember Template API.
An example usage of this helper in a template is: (array 'a' 'b' 'c') which would return the value ['a', 'b', 'c'].
All in all, this is a great addition to the Ember API. While it will add a minuscule size increase to the framework, the hole that it fills makes up for it.
Html-Safe-Helper: Sometimes you need to consume html to display it in a template. What if that html contained script tags or a malicious iframe? To use this type of content, it’s best to run it through the htmlSafe function to create a SafeString. This work is usually done outside of the template, and without a framework provided helper, so you would create a component that is otherwise unnecessary. Moreover, you could install ember-cli-string-helpers. RFC#319 encourages the adoption of a framework provided html-safe helper. The RFC already has strong support with a majority of the conversation focusing on the naming of the helper and if the triple curlies should be deprecated.
Key functions for each / each-in: The Glimmer VM uses a diffing algorithm to determine when to re-render a loop. The default key strategy used in the algorithm is usually good enough in most cases to detect when a loop has changed. RFC#321 enhances change detection by augmenting the default key strategies with user defined functions. This increased flexibility allows you to assemble composite keys from many different properties of an object or even from properties on objects whose fields are out of your control.
At this point we would like to remind you that the RFC process is a workflow doing just what its name says: asking for comments of the community, also know as you. ❤️Check out any of the RFCs we mentioned above and let your opinion, suggestions and thoughts be heard.
Are you a writer at heart and do you also love Ember? If you’re writing blog posts or if you’re getting into writing on the web, check out the ember tag of the Frontend Weekly and get your Ember-related articles featured on their site. You can submit any posts of yours to firstname.lastname@example.org to get them published on their curated list of Ember articles.
Still feeling a bit timid about blogging in general or you simply don’t know where to start? Pop by the #team-learning Slack channel to ask about and discuss Ember-related topics that might become the theme of your next post and join others in writing about Ember! ✍️✨
And pssst...just in case you haven’t joined the Emberista crowd on Slack yet, you definitely should. Get your invite to the channel right here.
Ember CLI team member @kellyselden will talk about his current efforts to bring that miracle import to Ember apps of the future. You can read his full answer to this question on the official Ember forum via the button below.
The Ember Inspector crew has been hard at work modernizing our dev tools experience to be cutting edge and compete with the features and aesthetics enjoyed in other frameworks’ dev tools. The first step towards this was the introduction of a component tree, which removes the table view we are used to, and just shows a tree of your Ember components alongside the properties that belong to that component.
This is a very early iteration, and styles and functionality will continue to improve, but we are excited for the direction things are going in and wanted to thank @bestra and @nummi for spearheading this effort! 💪
You can check out their work here and also meet with the Ember Inspector crew on Slack at #ember-inspector.