tmpvar/vec2.js — pull request #1 by dominictarr (2013-04-07 09:45:17+00:00)
Title: Don't notify observer unless value has actually changed.

With this it's possible to set up two way bindings, example - say we want two points that are always 10 units apart.

``` js
function bound2(a, x, y) {
var b = new Vec2(a.x + (x || 0), a.y + (y || 0))
b.change(function () {
a.set(b.x - (x || 0), b.y - (y || 0)
})
a.change(function () {
b.set(a.x + (x || 0), a.y + (y || 0))
})
}

var a = new Vec2(0, 1)
var b = bound2(a, 0, 10)

function log(a, name) {
a.change(function () {
console.log(name, a.x, a.y)
})
}

log(a, 'A'); log(b, 'B')

//changing a updates b
a.set(Math.random(), Math.random())
//changing b updates a !
b.set(Math.random(), Math.random())
```

I'm getting a funny feeling that you are building a CAD system :+1: