Created
September 5, 2019 20:50
-
-
Save scripting/a1108dd5a394c1e1886d4fc6bbcfcbdf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "test", | |
"description": "Test app for persists package.", | |
"author": "Dave Winer <[email protected]>", | |
"license": "MIT", | |
"version": "0.4.0", | |
"dependencies" : { | |
"persists": "*" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const utils = require ("daveutils"); | |
const persists = require ("persists"); | |
var initialstats = { | |
ct: 0, | |
slogan: "", | |
randomNumber: 0 | |
}; | |
var stats; | |
function everySecond () { | |
stats.ct++; | |
stats.slogan = utils.getRandomSnarkySlogan (); | |
stats.randomNumber = utils.random (0, 10000); | |
} | |
persists ("stats", initialstats, function (theProxy) { | |
stats = theProxy; | |
setInterval (everySecond, 1000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment