Friday, April 26, 2024
HomeJavaScriptThe Ember Instances - Problem No. 164

The Ember Instances – Problem No. 164


👋 Emberistas! 🐹

Hacktoberfest + The Ember Instances ✍️,
a brand new reference web page for Ember CLI instructions 🔖,
migrating off of mixins in Ember Octane 👋,
async knowledge and autotracking in Ember Octane ✨,
autotracking developer expertise 🔥,
ember-concurrency 2.0.0.beta-1 🎉,
and final, however not least, EmberJS with REST API 💪!


Hacktoberfest is a celebration of open supply open to everybody within the world GitHub group. Whether or not you’re a developer, scholar studying to code, occasion host, or firm of any dimension, you’ll be able to assist drive development of open supply and make optimistic contributions to an ever-growing group. All backgrounds and ability ranges are inspired to finish the problem!

Want concepts for Hacktoberfest contributions? Or trying to get began in open supply? We propose working with us on the subsequent Ember Instances subject! As you might know, The Ember Instances is the e-newsletter for the official Ember Weblog. As author, you’ll tackle an energetic function within the Ember group and sustain with the newest occasions and discoveries. Prior expertise in technical writing is not required, as we can be completely satisfied to mentor and pair with you. We additionally encourage everybody across the globe to affix; don’t be concerned if English is your second language (or third, and so on.).

Are you ? You may attain out to the crew in a number of alternative ways:

Along with supporting Ember and open supply, members will obtain a restricted version T-shirt or can select to plant a tree! We sit up for listening to from you quickly! 🥰


The Ember CLI Guides has a brand new webpage that lists all Ember CLI instructions. Please bookmark it for reference and onboarding new builders.

As you’ll be able to think about, the record of instructions and command choices grew over time so documenting it for the CLI Guides wasn’t a trivial process. We might like to acknowledge Tim (@fozy81) for his or her wonderful contribution. 💯

As at all times, you’ll be able to examine instructions and command choices in your terminal by operating ember --help. Please be happy to supply suggestions for the brand new webpage. Should you see incorrect or lacking data, you’ll be able to open a difficulty within the cli-guides repo.


Greetings from Ember Instances HQ! We had a Readers’ Query are available:

What is the advisable various for Ember.Mixin in Octane?

In Traditional Ember, should you needed to outline a chunk of DOM habits that you possibly can reuse throughout your software, you’d outline a part Mixin that applied the suitable lifecycle hooks. As of Ember 3.15, the Ember undertaking recommends Ember Octane for brand new purposes and addons. And idiomatic Octane recommends that you simply keep away from mixins. Going again to Octane is Right here, Yehuda Katz (@wycats) offers a migration instance. Aspect modifiers present a brand new strategy to reuse DOM habits, with out a few of the drawbacks that mixins have.

Earlier than (Traditional Ember): Mixins

import Mixin from '@ember/object/mixin';

export default Mixin.create({
  didInsertElement() {
    this._super();
    activateTabs(this.ingredient);
  }

  willDestroyElement() {
    this._super();
    deactivateTabs(this.ingredient);
  }
})

And then you definately would use the Mixin in a part like this:

import Element from '@ember/part';

export default Element.lengthen(Tabs, {
  // ...
});

After (Ember Octane): Aspect modifiers

That is what our Tabs mixin appears to be like like when reimplemented as a modifier.

import { modifier } from 'ember-modifier';

export default modifier(ingredient => {
  activateTabs(ingredient);

  return () => deactivateTabs(ingredient);
});

Since ingredient modifiers work on any ingredient, you needn’t create an entire part to create reusable DOM habits. You should use a modifier on any ingredient with this ingredient modifier syntax.

<div {{tabs}}></div>

Persevering with additional as regards to mixins, Chris Krycho (@chriskrycho) lately blogged about Migrating Off of PromiseProxyMixin in Ember Octane. A standard sample in lots of Traditional Ember apps and addons was to make use of PromiseProxyObject mixin with ObjectProxy to show the state of a promise to finish customers, and to make accessing the resolved knowledge extra handy. Make sure to learn the weblog submit for a deeper dive into a number of steered methods to strategy a rewrite with a light-weight, auto-tracked, and Octane-ready resolution.

P.S. Seeking to future-proof no mixins in your codebase? We propose enabling the useful no-mixins rule on eslint-plugin-ember.


A brand new weblog submit from Chris Krycho (@chriskrycho) talks about Async Information and Autotracking in Ember Octane. This weblog submit is a continuation of our earlier writeup on Migrating Off of PromiseProxyMixin in Ember Octane, which describes a strategy to divest mixin and inheritance in favor of composition. Chris does this through the use of a load helper and a brand new AsyncData construction.

The brand new weblog goes via treating that AsyncData as odd knowledge, however ensuring to deal with all states (loading, loaded, error). By integrating with tracked properties, the AsyncData class reacts to its modeled states and internals, dealing with this transition for us. This allows us to entry the information returned from the load helper as regular knowledge and react based mostly on its state.

import Element from '@glimmer/part';
import { load } from 'my-app/helpers/load';
import { fetchSomeData } from 'my-app/knowledge/fetchers';

export default class Neato extends Element {
  get knowledge() {
    return load(fetchSomeData(this.args.userId));
  }

  get displayData() {
    swap (this.knowledge.state) {
      case 'LOADING':
        return 'loading...';
      case 'LOADED':
        return this.knowledge.worth;
      case 'ERROR':
        return `Whoops! One thing went incorrect! ${this.knowledge.error.message}`;
    }
  }
}

Learn extra on the full weblog submit on Chris’s weblog.


Should you could not get sufficient from Chris Krycho (@chriskrycho), there’s much more! 😄

How does autotracking in Ember or Glimmer work? How does it enhance developer expertise? Which pc science ideas make it attainable? (Reply: Lamport clocks 🤯)

Should you’re able to be taught a bit extra about how environment friendly the autotracking system in Ember or Glimmer apps might be, you need to head on over to the submit.

Relaxation assured, it is a fairly approachable clarification of some complicated subjects that we as Ember customers profit from in an Octane world. All are inspired to go test it out!


There is a new beta launch of ember-concurrency! Due to the onerous work of Max Fierke (@maxfierke) 2.0.0.beta-1 introduces @tracked on Ember 3.16+, removes the power to instantly use the {{motion}} helper, and removes the get and set compatibility strategies from Process, TaskGroup, and TaskInstance.

As Max mentions in his tweet, 2.x is basically suitable with 1.x. For customers that preserve addons that rely upon ember-concurrency, it might be very useful if you should utilize a wider model vary in order that some people can attempt the two.x betas and others can improve once they’re capable of.

Extra details about this and about upgrading to 2.0.0-beta.1 and different future 2.x releases in
common might be discovered within the improve doc.

Go forward and provides the launch notes a learn.


John Costanzo (@jrock2004) wrote a weblog titled EmberJS with REST API. The weblog explains easy methods to get your APIs to work properly with Ember Information out of the field, if it follows REST API conventions. In case your APIs do not observe REST conventions, the submit offers particulars about easy methods to modify your Ember app serializer to make it work with Ember Information.

The weblog additionally discusses utilizing keyForAttribute to make a few of the guide work a bit of simpler, so that you simply don’t have to map every API property to the Ember mannequin property. Head over to the weblog submit at present and provides it a learn.


This week we might wish to thank Amy Lam (@amyrlam), Ben Demboski (@bendemboski), Bryan Mishkin (@bmish), Jan Bobisud (@bobisjan), Chad Hietala (@chadhietala), Godfrey Chan (@chancancode), Chris Ng (@chrisrng), Cory Loken (@cloke), Dmytro Krekota (@dmytro-krekota), Tim (@fozy81), Ava Gaiety Wroten (@hergaiety), Isaac Lee (@ijlee2), @JamesS-M, Jared Galanis (@jaredgalanis), Jen Weber (@jenweber), Jacob (@jfdnc), Katie Gengler (@kategengler), Kelly Selden (@kellyselden), Dave Laird (@kiwiupover), Ilya Radchenko (@knownasilya), Chris Manson (@mansona), @patricklx, Chris Garrett (@pzuraq), Raido Kuli (@raido), Ruslan Hrabovyi (@ro0gr), Volodymyr Radchenko (@rreckonerr), Robert Jackson (@rwjblue), Sergey Astapov (@SergeAstapov), Scott Newcomer (@snewcomer), Nicolas Fléron (@tempo22), and Yehuda Katz (@wycats) for his or her contributions to Ember and associated repositories! 💖


Office Hours Tomster Mascot

Questioning about one thing associated to Ember, Ember Information, Glimmer, or addons within the Ember ecosystem, however do not know the place to ask? Readers’ Questions are only for you!

Submit your personal quick and candy query underneath bit.ly/ask-ember-core. And don’t fear, there aren’t any foolish questions, we recognize all of them – promise! 🤞

Wish to write for the Ember Instances? Have a suggestion for subsequent week’s subject? Be a part of us at #support-ember-times on the Ember Group Discord or ping us @embertimes on Twitter.

Carry on high of what is been occurring in Emberland this week by subscribing to our e-mail e-newsletter! You may also discover our posts on the Ember weblog.


That is one other wrap! ✨

Be sort,

Abhilash LR, Chris Ng, Jared Galanis, Isaac Lee, Amy Lam and the Studying Group



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments