can.Construct


can.Observe

In Controls you should not worry about unbinding.

Ever need to unbind manually?

Also let bind to add, remove and set.

Observable pattern

http://addyosmani.com/resources/essentialjsdesignpatterns/book/#observerpatternjavascript

The Observer is a design pattern where an an object (known as a subject) maintains a list of objects depending on it (observers), automatically notifying them of any changes to state.

When a subject needs to notify observers about something interesting happening, it broadcasts a notification to the observers (which can include specific data related to the topic of the notification).

When we no longer wish for a particular observer to be notified of changes by the subject they are registered with, the subject can remove them from the list of observers.

It's often useful to refer back to published definitions of design patterns that are language agnostic to get a broader sense of their usage and advantages over time. The definition of the Observer pattern provided in the GoF book, Design Patterns: Elements of Reusable Object-Oriented Software, is:

"One or more observers are interested in the state of a subject and register their interest with the subject by attaching themselves. When something changes in our subject that the observer may be interested in, a notify message is sent which calls the update method in each observer. When the observer is no longer interested in the subject's state, they can simply detach themselves."

We can now expand on what we've learned to implement the Observer pattern with the following components:

Subject: maintains a list of observers, facilitates adding or removing observers

Observer: provides a update interface for objects that need to be notified of a Subject's changes of state

Observer vs Pub/sub

Pub/sub is variation.

The Observer pattern requires that the observer (or object) wishing to receive topic notifications must subscribe this interest to the object firing the event (the subject).

The Publish/Subscribe pattern however uses a topic/event channel which sits between the objects wishing to receive notifications (subscribers) and the object firing the event (the publisher). This event system allows code to define application specific events which can pass custom arguments containing values needed by the subscriber. The idea here is to avoid dependencies between the subscriber and publisher.

This differs from the Observer pattern as it allows any subscriber implementing an appropriate event handler to register for and receive topic notifications broadcast by the publisher.


can.Model


frag - lightweight collection of DOM elems. Can be used with jQuery DOM methods.

Model service methods return defers.

Load and cache JS templates.

Like Angular angular.element($0).scope()


Elems already has jQuery methods.