reactivity
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -50,2 +50,12 @@ // Generated by CoffeeScript 1.6.3 | ||
( they will be provisioned by the current monitor ) | ||
returns 'undefined' if reactivity is not active in this call stack. | ||
In previous versions we returned a NOOP function. | ||
While returning undefined imposes a burden on the developer | ||
( he has to check for this condition ), by making him aware of the fact | ||
that reactivity may not always be active, we give him an opportunity to perform | ||
some optimizations. | ||
After reviewing several apps I have noticed that this is indeed a very common | ||
situation. | ||
*/ | ||
@@ -52,0 +62,0 @@ |
@@ -32,8 +32,32 @@ // Generated by CoffeeScript 1.6.3 | ||
main = function() { | ||
var c; | ||
c = cell(); | ||
if (arguments.length === 1) { | ||
c(arguments[0]); | ||
var a, inv, is_func, r; | ||
inv = function() { | ||
throw new Error('invalid arguments ', arguments); | ||
}; | ||
is_func = function(v) { | ||
return typeof v === 'function'; | ||
}; | ||
a = arguments; | ||
switch (a.length) { | ||
case 0: | ||
return cell(); | ||
case 1: | ||
if (is_func(a[0])) { | ||
return run(a[0]); | ||
} else { | ||
r = cell(); | ||
r(a[0]); | ||
return r; | ||
} | ||
break; | ||
case 2: | ||
if (is_func(a[0]) && is_func(a[1])) { | ||
return subscribe(a[0], a[1]); | ||
} else { | ||
return inv(); | ||
} | ||
break; | ||
default: | ||
return inv(); | ||
} | ||
return c; | ||
}; | ||
@@ -40,0 +64,0 @@ main.notifier = notifier; |
{ | ||
"name": "reactivity", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Native Reactivity for Javascript", | ||
@@ -5,0 +5,0 @@ "author": "Aldo Bucchi <aldo.bucchi@gmail.com>", |
@@ -13,7 +13,17 @@ /* | ||
function r(): r.Cell<any> ; | ||
/* | ||
Proxies to run() when called with one argument of type function | ||
*/ | ||
function r<T>( f: r.Block<T> ) : r.Result<T> ; | ||
/* | ||
Returns a cell initialized to @value | ||
Returns a cell initialized to @value when called with one argument that is not a function | ||
*/ | ||
function r<T>( value: T ): r.Cell<T> ; | ||
/* | ||
Proxies to subscribe() when called with two arguments of type function | ||
*/ | ||
function r<T>( f: r.Block<T>, c: r.Callback<T> ) : r.Stopper ; | ||
@@ -20,0 +30,0 @@ module r { |
212865
4410