Ember Singularity integrates a Unified Event Handlerservice to help control DOM event listeners by taking normal DOM events andbinding them to Ember Events that are triggered by a singular DOM listener.
In other words, this means that instead of having multiple listeners for asingle DOM event, you have one listener for a single DOM event that thentriggers multiple callbacks via Ember events.
Why do this? There are two primary motivations:
The available interface for the UnifiedEventHandler
is pretty simple and onlycontains 3 available methods. That said, it is recommended that you abstractaway any usage of the service via mixins or base-level components; this helpsensure the benefits described in the above motivations.
register(target, eventName, callback)
This registers a callback to be tied to a specific target and event type. Thetarget
and eventName
are expected to be of type string
and callback
is afunction. The callback
will receive the original event. Here's an example:
let ScrollMixin = Ember.Mixin.extend({
unifiedEventHandler: Ember.inject.service(),
_registerScrollCallback: Ember.on('init', function() {
this.get('unifiedEventHandler').register('window', 'scroll', (event) => {
console.log('scrolled!');
console.log(event);
});
})
});
unregister(target, eventName, callback)
This is the exact opposite of register()
and expects the arguments to be thesame as were used to register the handler. Here's an example:
let ScrollMixin = Ember.Mixin.extend({
unifiedEventHandler: Ember.inject.service(),
scroll() { console.log('scrolled!'); },
_registerScrollCallback: Ember.on('init', function() {
this.get('unifiedEventHandler').register('window', 'scroll', this.scroll);
}),
_unregisterScrollCallback: Ember.on('willDestroy', function() {
this.get('unifiedEventHandler').unregister('window', 'scroll', this.scroll);
})
});
triggerEvent(eventName)
This allows you to trigger the Ember event that your callback got bound to. Asof version 1.1.0, after you register a handler it's Ember event will be of theform <event-name>.<target>
. This probably won't be used often, but isavailable for flexibility in testing, debugging, and extending functionality.Here's a final example of the total API:
let ScrollMixin = Ember.Mixin.extend({
unifiedEventHandler: Ember.inject.service(),
scroll() { console.log('scrolled!'); },
triggerScroll() {
this.get('unifiedEventHandler').triggerEvent('window.scroll');
},
_registerScrollCallback: Ember.on('init', function() {
this.get('unifiedEventHandler').register('window', 'scroll', this.scroll);
}),
_unregisterScrollCallback: Ember.on('willDestroy', function() {
this.get('unifiedEventHandler').unregister('window', 'scroll', this.scroll);
})
});
Ember检查器是一个浏览器插件,用于调试Ember应用程序。 灰烬检查员包括以下主题 - S.No. 灰烬检查员方式和描述 1 安装Inspector 您可以安装Ember检查器来调试您的应用程序。 2 Object Inspector Ember检查器允许与Ember对象进行交互。 3 The View Tree 视图树提供应用程序的当前状态。 4 检查路由,数据选项卡和库信息 您可以看到检查
英文原文: http://emberjs.com/guides/getting-ember/index/ Ember构建 Ember的发布管理团队针对Ember和Ember Data维护了不同的发布方法。 频道 最新的Ember和Ember Data的 Release,Beta 和 Canary 构建可以在这里找到。每一个频道都提供了一个开发版、最小化版和生产版。更多关于不同频道的信息可以查看博客
ember-emojione ember-emojione is your emoji solution for Ember, based on the EmojiOne project. EmojiOne version 2 is used, which is free to use for everyone (CC BY-SA 4.0), you're only required to giv
Ember 3D Ember 3D is an Ember addon for using Three.js - an easy to use, lightweight, javascript 3D library. It is designed to: Prescribe a solid file structure to Three.js code using ES6 modules. Ena
Ember Table An addon to support large data set and a number of features around table. Ember Table canhandle over 100,000 rows without any rendering or performance issues. Ember Table 3.x supports: Emb
vscode-ember This is the VSCode extension to use the Ember Language Server. Features All features currently only work in Ember-CLI apps that use classic structure and are a rough first draft with a lo
ember-headlessui This is a work-in-progress implementation of: https://github.com/tailwindlabs/headlessui A set of completely unstyled, fully accessible UI components for Ember.js, designed to integra
Ember Popper An Ember-centric wrapper around Popper.js. Currently an alpha in active development. See the dummy app for examples Compatibility Ember.js v3.12 or above Ember CLI v2.13 or above Node.js