Skip to content

Commit 25b0702

Browse files
committed
v2.0
1 parent 4ce6693 commit 25b0702

3 files changed

Lines changed: 6 additions & 10 deletions

File tree

index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,24 +1636,21 @@
16361636
var isInitData = !fs.existsSync(filePath),
16371637
isFileProcessing = false,
16381638
isWrited = false,
1639-
writeTimeout,
1640-
lastModifiedTime = Date.now();
1639+
writeTimeout;
16411640

16421641
if (!data) { data = createDataContext({}); }
16431642
if (!data._isDataContext) { data = createDataContext(data); }
16441643

1645-
fs.watchFile(filePath, (curr, prev) => {
1644+
fs.watchFile(filePath, (/*curr, prev*/) => {
16461645

16471646
if (isWrited) { isWrited = false; return; }
1648-
if (lastModifiedTime > curr.mtimeMs) { return; }
16491647

16501648
readFileSync();
16511649
});
16521650

16531651
data.on('-change', (event) => {
16541652

16551653
writeFileSync();
1656-
isWrited = true;
16571654

16581655
// I am alive.
16591656
return true;
@@ -1748,11 +1745,10 @@
17481745
strJson = createDataContext.stringify(data, null, 2);
17491746

17501747
isInitData = false;
1748+
isWrited = true;
17511749

17521750
fs.writeFileSync(filePath, strJson, { encoding: 'utf8', flag: 'w', flush: true });
17531751

1754-
//data.resetChanges();
1755-
lastModifiedTime = Date.now();
17561752
isFileProcessing = false;
17571753

17581754
if (onDataChange) {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "data-context",
33
"description": "Watch data changes in the browser and node.js",
4-
"version": "2.0.0-beta.27",
4+
"version": "2.0.0-beta.28",
55
"license": "MIT",
66
"keywords": [
77
"on",

0 commit comments

Comments
 (0)