sigvalue
The Signaled Value library for javascript.
Usage
After installation the only thing you need to do is require the module:
var sigvalue = ;
Class Signal
var s = context = foo: 'bar' ; { console; // true} s;s;s;
Signal accept an extra argument which is the context or this value that should be set for the emitted signal. This means you no longer have the overhead of an event that required fn.bind
in order to get a custom this value.
Class Value
Class Value has the following signals:
thischanged = ;thisitemSpliced = ;thispropUpdated = ;
When Value
presents a single string, number or object, call Value.set
method will emit the changed signal.
var s = 1;schanged s;
When Value
used as Array, the itemSpliced signals will emit when call push
pop
shift
unshift
splice
update
method.
var s = 1 2; sitemSpliced; s;
When Value
used as Object, the propUpdated signals will emit when call setProp
or deleteProp
method.
var s = ; spropUpdated; s;
To get the raw object of Value
, use get()
method
var o = var s = o;ifs === o // get the raw object