persvr / perstore

CommonJS persistence/object storage based on W3C's object store API.
http://www.persvr.org/
96 stars 20 forks source link

Passing path during creation does not call .setPath #37

Closed kitsonk closed 6 months ago

kitsonk commented 12 years ago

It appears that passing in of path upon construction of a store does not properly invoke setPath() which then causes the store/notifying wrapper to not initialise its message hub properly. For example:

var store = require("perstore/store").DefaultStore({
  path: "store",
  filename: "bar.json"
});
store.add({ foo: "bar" });

Will produce something like:

/node_modules/perstore/store/notifying.js:66
                localHub.publish({
                         ^
TypeError: Cannot call method 'publish' of undefined
    at exports.Notifying.store.add (/node_modules/perstore/store/notifying.js:66:14)
    at exports.when (/node_modules/perstore/node_modules/promised-io/promise.js:360:29)
    at Object.exports.Notifying.store.add (/node_modules/perstore/store/notifying.js:64:11)
    at Object.defineProperties.save.value (/node_modules/perstore/facet.js:432:27)
    at Object.constructor.add (/node_modules/perstore/facet.js:203:39)

Where as the following removes the issue:

var store = require("perstore/store").DefaultStore({
  path: "store",
  filename: "bar.json"
});
store.setPath("store");
store.add({ foo: "bar" });