Infrastructure

Use

The infrastructure collection of libraries are lower-level utility libraries that
are used by the Core and Ecosystem collections. They can also
be used by applications directly.

Let’s explore what’s available.

can-event

can-event is a mixin that adds event dispatching and listening functionality
on your objects. The following shows creating a Person constructor function
whose instances can produce events that can be listened to.

can-observation

can-observation provides a mechanism to notify when an observable has been read and a way to observe those reads called within a given function. can-observation provides the foundation for can-compute’s abilities.

Use Observation.add to signal when an an observable value has been read.
The following makes the Person type’s getName() observable:

This is to say that the #if over21 nodeList will contain a text node for "name:"
and the highlight name nodeList. The highlight name nodeList will contain the
html content resulting from that helper (<b>Justin</b>).

can-view-scope

can-view-scope provides a lookup node within a contextual lookup. This is similar
to a call object in closure in JavaScript. Consider how message, first, and last are looked up in the following JavaScript: