Objects, Properties & Actions
Nearly all of Ember's important types extend from a core Ember.Object
class, which we'll study, and compare to JavaScript's Object
and Class
concepts.
Some types of ember objects, like Routes, Controllers and Components can handle user interactions by way of actions. We'll cover strategies and best practices for action handling, including:
- the
{{action}}
helper - closure actions
- action bubbling
- the
{{route action}}
helper - the
{{mut}}
helper
-
Objects, Properties & ActionsObjects
We'll look at
Ember.Object
in detail, including:- using the KVO-compliant get and set methods
- adding instance and static methods with
reopen
andreopenClass
- lifecycle hooks
- events
-
Objects, Properties & ActionsExercise: Extending Object
We'll create our own subclass of
Ember.Object
usingextend()
, and incorporate:- proper handling of setup and tear-down logic
- firing events using
Ember.Evented
- getting and setting properties
- reopening
-
Objects, Properties & ActionsServices
Services are a means of sharing state & functionality across various aspects of an app. We'll explain what makes services a simple, but powerful concept, and illustrate service use via
Ember.inject
. Finally, we'll get a sneak preview of the important role services play in the upcoming engines framework feature, and explore the "do's and don'ts of service design*. -
Objects, Properties & ActionsExercise: Services
We'll improve our bound handlebars helper, and take advantage of a service, so that we can share the concept of "current time" across many flavors of objects, and perform more efficient DOM updates.
-
Objects, Properties & ActionsComputed Properties
Computed properties are a performant and intuitive way to define values that are based on other values. We'll take a short trip through the internal implementation of a computed property, and contrast it with the more expensive and error-prone concept of Observers.