examples/example-simple.js
function Person(firstname, lastname, middlenames) {
	Person.super_.call(this);

	var _priv = {
		first: firstname || '-unknown-',
		last: lastname || '-unknown-',
		middle: middlenames || '-unknown-'
	};

	this.defines
	.value('_state', {})
	.property('first_name',
		function() { return _priv.first; },
		function(first) {
			first = first || '-unknown-';
			if (first !== _priv.first) {
				var change = {
					what: 'first_name',
					from: _priv.first,
					to: first
				};
				_priv.first = first;
				this.emit('property-changed', change);
			}
		})

	.property('last_name',
		function() { return _priv.last; },
		function(last) {
			last = last || '-unknown-';
			if (last !== _priv.last) {
				var change = {
					what: 'last_name',
					from: _priv.last,
					to: last
				};
				_priv.last = last;
				this.emit('property-changed', change);
			}
		})

	.property('middle_names',
		function() { return _priv.middle; },
		function(middle) {
			middle = middle || '-unknown-';
			if (middle !== _priv.middle) {
				var change = {
					what: 'middle_names',
					from: _priv.middle,
					to: middle
				};
				_priv.middle = middle;
				this.emit('property-changed', change);
			}
		})
	;
}
function Person(firstname, lastname, middlenames) {
	Person.super_.call(this);

	var _priv = {
		first: firstname || '-unknown-',
		last: lastname || '-unknown-',
		middle: middlenames || '-unknown-'
	};

	this.defines
	.value('_state', {})
	.property('first_name',
		function() { return _priv.first; },
		function(first) {
			first = first || '-unknown-';
			if (first !== _priv.first) {
				var change = {
					what: 'first_name',
					from: _priv.first,
					to: first
				};
				_priv.first = first;
				this.emit('property-changed', change);
			}
		})

	.property('last_name',
		function() { return _priv.last; },
		function(last) {
			last = last || '-unknown-';
			if (last !== _priv.last) {
				var change = {
					what: 'last_name',
					from: _priv.last,
					to: last
				};
				_priv.last = last;
				this.emit('property-changed', change);
			}
		})

	.property('middle_names',
		function() { return _priv.middle; },
		function(middle) {
			middle = middle || '-unknown-';
			if (middle !== _priv.middle) {
				var change = {
					what: 'middle_names',
					from: _priv.middle,
					to: middle
				};
				_priv.middle = middle;
				this.emit('property-changed', change);
			}
		})
	;
}
function Person ( firstname , lastname , middlenames ) { Person . super_ . call ( this ) ; var _priv = { first : firstname || '-unknown-' , last : lastname || '-unknown-' , middle : middlenames || '-unknown-' } ; this . defines . value ( '_state' , { } ) . property ( 'first_name' , function ( ) { return _priv . first ; } , function ( first ) { first = first || '-unknown-' ; if ( first !== _priv . first ) { var change = { what : 'first_name' , from : _priv . first , to : first } ; _priv . first = first ; this . emit ( 'property-changed' , change ) ; } } ) . property ( 'last_name' , function ( ) { return _priv . last ; } , function ( last ) { last = last || '-unknown-' ; if ( last !== _priv . last ) { var change = { what : 'last_name' , from : _priv . last , to : last } ; _priv . last = last ; this . emit ( 'property-changed' , change ) ; } } ) . property ( 'middle_names' , function ( ) { return _priv . middle ; } , function ( middle ) { middle = middle || '-unknown-' ; if ( middle !== _priv . middle ) { var change = { what : 'middle_names' , from : _priv . middle , to : middle } ; _priv . middle = middle ; this . emit ( 'property-changed' , change ) ; } } ) ; }
Simple observable person object
Simple observable person object