mobservable
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -74,4 +74,9 @@ /** | ||
}; | ||
mobservableStatic.toJSON = function toJSON(value) { | ||
if (value instanceof ObservableArray) | ||
return value.values(); | ||
return value; | ||
}; | ||
mobservableStatic.batch = function batch(action) { | ||
Scheduler.batch(action); | ||
return Scheduler.batch(action); | ||
}; | ||
@@ -688,3 +693,3 @@ mobservableStatic.onReady = function onReady(listener) { | ||
try { | ||
action(); | ||
return action(); | ||
} | ||
@@ -691,0 +696,0 @@ finally { |
@@ -16,6 +16,8 @@ declare module "mobservable" { | ||
export function toJSON<T>(any:T):T; | ||
// annotation | ||
export function observable(target:Object, key:string); | ||
export function batch(action:Lambda); | ||
export function batch<T>(action:()=>T):T; | ||
export function onReady(listener:Lambda):Lambda; | ||
@@ -22,0 +24,0 @@ export function onceReady(listener:Lambda); |
@@ -25,3 +25,5 @@ /** | ||
watch<T>(func:()=>T, onInvalidate:Lambda):[T,Lambda]; | ||
toJSON<T>(any:T):T; | ||
// property definition | ||
@@ -34,3 +36,3 @@ observable(target:Object, key:string); // annotation | ||
// batching | ||
batch(action:Lambda); | ||
batch<T>(action:()=>T):T; | ||
onReady(listener:Lambda):Lambda; | ||
@@ -150,6 +152,13 @@ onceReady(listener:Lambda); | ||
mobservableStatic.batch = function batch(action:Lambda) { | ||
Scheduler.batch(action); | ||
mobservableStatic.toJSON = function toJSON<T>(value:T):T { | ||
if (value instanceof ObservableArray) | ||
return (<any>value).values(); | ||
// later on, more cases like objects and such | ||
return value; | ||
} | ||
mobservableStatic.batch = function batch<T>(action:()=>T):T { | ||
return Scheduler.batch(action); | ||
} | ||
mobservableStatic.onReady = function onReady(listener:Lambda):Lambda { | ||
@@ -842,6 +851,6 @@ return Scheduler.onReady(listener); | ||
static batch(action:Lambda) { | ||
static batch<T>(action:()=>T):T { | ||
Scheduler.inBatch += 1; | ||
try { | ||
action(); | ||
return action(); | ||
} finally { | ||
@@ -848,0 +857,0 @@ //Scheduler.inBatch -= 1; |
{ | ||
"name": "mobservable", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "Changes are coming! Small library for creating observable properties en functions", | ||
@@ -5,0 +5,0 @@ "main": "dist/mobservable.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90584
1767