1.0.0 • Published 11 years ago

watchvar v1.0.0

Weekly downloads
2
License
-
Repository
github
Last release
11 years ago

watcher

A simple utility, which allows you to detect if a variable has changed.

Installation

npm install watcher

Usage

var watcher = require("watcher");
var myVariable = 2;

var myVariableWatcher = watcher.watch(myVariable, function(newValue) {
    console.log("myVariable = %d", newValue);
    watcher.unwatch(myVariableWatcher);
});

// Change myVariable after 5 seconds
setTimeout(function() {
    myVariable = Math.random() * 99;
}, 5000);