Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mobservable

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobservable - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

29

mobservable.js

@@ -0,1 +1,2 @@

/// <reference path="./typings/node-0.10.d.ts" />
var __extends = this.__extends || function (d, b) {

@@ -7,3 +8,7 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

};
/// <reference path="./typings/node-0.10.d.ts" />
/**
* MOBservable
* (c) 2015 - Michel Weststrate
* https://github.com/mweststrate/mobservable
*/
var events = require('events');

@@ -26,2 +31,18 @@ function property(value, scope) {

exports.property = property;
function guard(func, onInvalidate) {
var dnode = new DNode();
var retVal;
dnode.compute = function (done) {
retVal = func();
dnode.compute = function (done2) {
done2();
dnode.dispose();
onInvalidate();
};
done();
};
dnode.computeNextValue();
return [retVal, function () { return dnode.dispose(); }];
}
exports.guard = guard;
function batch(action) {

@@ -226,2 +247,8 @@ Scheduler.batch(action);

};
DNode.prototype.dispose = function () {
var _this = this;
this.observing.forEach(function (observing) { return observing.removeObserver(_this); });
this.observing = [];
// Do something with the observers, notify some state like KILLED?
};
/*

@@ -228,0 +255,0 @@ Dependency detection

/// <reference path="./typings/node-0.10.d.ts" />
/**
* MOBservable
* (c) 2015 - Michel Weststrate
* https://github.com/mweststrate/mobservable
*/
import events = require('events');

@@ -33,2 +40,18 @@

export function guard<T>(func:()=>T, onInvalidate:Lambda):[T,Lambda] {
var dnode = new DNode();
var retVal:T;
dnode.compute = function(done) {
retVal = func();
dnode.compute = function(done2) {
done2();
dnode.dispose();
onInvalidate();
}
done();
}
dnode.computeNextValue();
return [retVal, () => dnode.dispose()];
}
export function batch(action:Lambda) {

@@ -260,2 +283,8 @@ Scheduler.batch(action);

}
public dispose() {
this.observing.forEach(observing => observing.removeObserver(this));
this.observing = [];
// Do something with the observers, notify some state like KILLED?
}
}

@@ -262,0 +291,0 @@

47

package.json
{
"name": "mobservable",
"version": "0.0.1",
"description": "Changes are coming! Small library for creating observable properties en functions",
"main": "mobservable.js",
"scripts": {
"test": "node_modules/.bin/nodeunit test/",
"prepublish": "node_modules/typescript-require/node_modules/typescript/bin/tsc -m commonjs -t ES5 mobservable.ts"
},
"repository": {
"type": "git",
"url": "https://github.com/mweststrate/mobservable.git"
},
"author": "Michel Weststrate",
"license": "MIT",
"bugs": {
"url": "https://github.com/mweststrate/mobservable/issues"
},
"homepage": "https://github.com/mweststrate/mobservable",
"devDependencies": {
"nodeunit": "^0.9.1",
"typescript-require": "^0.2.8"
}
}
"name": "mobservable",
"version": "0.0.2",
"description": "Changes are coming! Small library for creating observable properties en functions",
"main": "mobservable.js",
"scripts": {
"test": "node_modules/.bin/nodeunit test/",
"prepublish": "node_modules/typescript-require/node_modules/typescript/bin/tsc -m commonjs -t ES5 mobservable.ts"
},
"repository": {
"type": "git",
"url": "https://github.com/mweststrate/mobservable.git"
},
"author": "Michel Weststrate",
"license": "MIT",
"bugs": {
"url": "https://github.com/mweststrate/mobservable/issues"
},
"homepage": "https://github.com/mweststrate/mobservable",
"devDependencies": {
"nodeunit": "^0.9.1",
"nscript": "^0.1.5",
"typescript-require": "^0.2.8"
}
}

@@ -70,2 +70,10 @@ # MOBservable

### mobservable.guard(func, onInvalidate)
`guard` invokes `func` and returns a tuple consisting of the return value of `func` and an unsubscriber. `guard` will track which observables `func` was observing, but it will *not* recalculate `func` if necessary, instead, it will fire the `onInvalidate` callback to notify that the output of `func` can no longer be trusted.
The `onInvalidate` function will be called only once, after that, the guard has finished. To abort a guard, use the returned unsubscriber.
Guard is useful in functions where you want to have `func` observable, but func is actually invoked as side effect or part of a bigger change flow or where unnecessary recalculations of `func` or either pointless or expensive.
### mobservable.batch(workerFunction)

@@ -72,0 +80,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc