Define values that you can subscribe for changes. Based on pubsub
message = attr('Hello World')
message()
// => Hello World
message.subscribe(function (update, old) {
console.log(update, old)
// => 你好, Hello World
})
message('你好')
message()
// => 你好
$ npm install attr
Creates and returns a new attr.
message = attr('Hello World')
message()
// => Hello World
To get the value of an attr, call it with no parameters:
message()
// => Hello World
To change the value of an attr, call the attr with new value:
message('Foo Bar')
message()
// => Foo Bar
Subscribes the given function to changes.
message.subscribe(function () {
message()
// => Lorem Ipsum
})
message('Lorem Ipsum')