From 4ebec3f55e4f5dcc14fd5e2682e7e047ff60d8f8 Mon Sep 17 00:00:00 2001 From: Olivier Scherrer Date: Sun, 5 Apr 2015 16:23:13 -0400 Subject: [PATCH] 0.0.4 also publish old values when using alter --- README.md | 6 ++++++ index.js | 4 ++-- package.json | 2 +- test/observable-store.spec.js | 8 ++++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 90c9173..4705cfd 100644 --- a/README.md +++ b/README.md @@ -237,6 +237,12 @@ store.loop(function (value, key, object) { }, scope /* optional */); ``` +CHANGELOG +========= + +### 0.0.4 5 APR 2015 + +* Publish old value too when altering the store LICENSE ======= diff --git a/index.js b/index.js index 0c81122..265c816 100644 --- a/index.js +++ b/index.js @@ -59,8 +59,8 @@ module.exports = function StoreConstructor($data) { "deleted", "added"].forEach(function (value) { diffs[value].forEach(function (dataIndex) { - _storeObservable.notify(value, dataIndex, _data[dataIndex]); - _valueObservable.notify(dataIndex, _data[dataIndex], value); + _storeObservable.notify(value, dataIndex, _data[dataIndex], previousData[dataIndex]); + _valueObservable.notify(dataIndex, _data[dataIndex], value, previousData[dataIndex]); }); }); }; diff --git a/package.json b/package.json index 12d4beb..2875dc3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "observable-store", "description": "An observable data store with dirty checking and computed properties", - "version": "0.0.3", + "version": "0.0.4", "homepage": "https://github.com/flams/observable-store", "licenses": [ { diff --git a/test/observable-store.spec.js b/test/observable-store.spec.js index f2053f2..849b877 100644 --- a/test/observable-store.spec.js +++ b/test/observable-store.spec.js @@ -80,7 +80,7 @@ describe("Store", function () { }); - it("should allow for returning a JSON version of the store", function () { + it("should return a JSON version of the store", function () { var values = { key1: "value1", key2: "value2" @@ -93,7 +93,7 @@ describe("Store", function () { expect(Object.getOwnPropertyNames(json).length).toBe(2); }); - it("should allow for deleting multiple indexes at once", function () { + it("should delete multiple indexes at once", function () { // I'd like to keep [2, 7, 10] in the end var indexes = [0, 9, 12, 4, 5, 6, 8, 1, 11, 3]; store.reset([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); @@ -226,8 +226,7 @@ describe("Store", function () { }); describe("value observable", function () { - var store = null, - storeObservable = null; + var store = null; beforeEach(function () { store = new Store(); @@ -481,6 +480,7 @@ describe("Store", function () { // call.args[0] should equal 2 or 3 expect(call.args[0] >= 2).toBe(true); expect(call.args[1]).toBeUndefined(); + expect(call.args[2] >= 2).toBe(true); }); });