ZNOW

class

instance

interface

abstract-class

extends

implements

private

protected

public

static

const

constructor

super

read-only

friendly-method

event

Event

Observer pattern is default in ZNOW. It is packaged as event. To add an event to a class, "EVENT" declaration has to be added.

After that, other objects can start observing the object by using "on" and stop observing by using "off".

To trigger the update, you can simply call "$on[EventName]".

var Clock=Class({ time:EVENT, // register an event init:function(){ var _this=this; setInterval(this(function(){ //notify all observers with parameters _this.$onTime('5 sec pass'); }), 5000); } }); var Observer=Class({ init:function(clock){ // attach an observer by passing a function clock.on('time', function(message){ alert(message); //will alert '5 sec pass' }); } });