{"_id":"podda","_rev":"471301","name":"podda","description":"Simple Reactive DataStore for JavaScript","dist-tags":{"latest":"1.2.2"},"maintainers":[{"name":"arunoda","email":"arunoda.susiripala@gmail.com"}],"time":{"modified":"2021-08-05T08:19:30.000Z","created":"2016-11-08T09:49:57.996Z","1.2.2":"2016-11-16T23:30:07.791Z","1.2.1":"2016-11-13T02:29:39.528Z","1.2.0":"2016-11-12T23:36:26.597Z","1.1.0":"2016-11-08T10:22:28.389Z","1.0.0":"2016-11-08T09:49:57.996Z"},"users":{},"repository":{"type":"git","url":"git+https://github.com/arunoda/podda.git"},"versions":{"1.2.2":{"name":"podda","version":"1.2.2","description":"Simple Reactive DataStore for JavaScript","repository":{"type":"git","url":"git+https://github.com/arunoda/podda.git"},"license":"MIT","scripts":{"prepublish":". ./.scripts/prepublish.sh","lint":"eslint src","lintfix":"eslint src --fix","testonly":"mocha --require .scripts/mocha_runner src/**/tests/**/*.js","test":"npm run lint && npm run testonly","test-watch":"npm run testonly -- --watch --watch-extensions js"},"devDependencies":{"babel-cli":"^6.14.0","babel-core":"^6.14.0","babel-eslint":"^6.1.2","babel-loader":"^6.2.5","babel-plugin-transform-runtime":"^6.15.0","babel-polyfill":"^6.13.0","babel-preset-react-app":"^0.2.1","chai":"^3.5.0","eslint":"^3.6.0","eslint-config-airbnb":"^12.0.0","eslint-plugin-import":"^1.16.0","eslint-plugin-jsx-a11y":"^2.2.2","eslint-plugin-react":"^6.6.0","mocha":"^3.0.2","sinon":"^1.17.6"},"dependencies":{"babel-runtime":"^6.11.6","immutable":"^3.8.1"},"main":"dist/index.js","engines":{"npm":"^3.0.0"},"gitHead":"3e9829e7b1aeb4e0ffc73c60a6b5f84dff3f53fe","bugs":{"url":"https://github.com/arunoda/podda/issues"},"homepage":"https://github.com/arunoda/podda#readme","_id":"podda@1.2.2","_shasum":"15b0edbd334ade145813343f5ecf9c10a71cf500","_from":".","_npmVersion":"4.0.0","_nodeVersion":"6.6.0","_npmUser":{"name":"arunoda","email":"arunoda.susiripala@gmail.com"},"dist":{"shasum":"15b0edbd334ade145813343f5ecf9c10a71cf500","size":31270,"noattachment":false,"key":"/podda/-/podda-1.2.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/podda/download/podda-1.2.2.tgz"},"maintainers":[{"name":"arunoda","email":"arunoda.susiripala@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/podda-1.2.2.tgz_1479339007562_0.9922614188399166"},"directories":{},"publish_time":1479339007791,"_cnpm_publish_time":1479339007791,"_hasShrinkwrap":false},"1.2.1":{"name":"podda","version":"1.2.1","description":"Simple Reactive DataStore for JavaScript","repository":{"type":"git","url":"git+https://github.com/arunoda/podda.git"},"license":"MIT","scripts":{"prepublish":". ./.scripts/prepublish.sh","lint":"eslint src","lintfix":"eslint src --fix","testonly":"mocha --require .scripts/mocha_runner src/**/tests/**/*.js","test":"npm run lint && npm run testonly","test-watch":"npm run testonly -- --watch --watch-extensions js"},"devDependencies":{"babel-cli":"^6.14.0","babel-core":"^6.14.0","babel-eslint":"^6.1.2","babel-loader":"^6.2.5","babel-plugin-transform-runtime":"^6.15.0","babel-polyfill":"^6.13.0","babel-preset-react-app":"^0.2.1","chai":"^3.5.0","eslint":"^3.6.0","eslint-config-airbnb":"^12.0.0","eslint-plugin-import":"^1.16.0","eslint-plugin-jsx-a11y":"^2.2.2","eslint-plugin-react":"^6.6.0","mocha":"^3.0.2","sinon":"^1.17.6"},"dependencies":{"babel-runtime":"^6.11.6","immutable":"^3.8.1"},"main":"dist/index.js","engines":{"npm":"^3.0.0"},"gitHead":"2f80c9952e847eb4b764b8deec8cdec12196d76d","bugs":{"url":"https://github.com/arunoda/podda/issues"},"homepage":"https://github.com/arunoda/podda#readme","_id":"podda@1.2.1","_shasum":"ea8d9d30a95eae9bdb736a52b2dc56fad5d21bd8","_from":".","_npmVersion":"4.0.0","_nodeVersion":"6.6.0","_npmUser":{"name":"arunoda","email":"arunoda.susiripala@gmail.com"},"dist":{"shasum":"ea8d9d30a95eae9bdb736a52b2dc56fad5d21bd8","size":31199,"noattachment":false,"key":"/podda/-/podda-1.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/podda/download/podda-1.2.1.tgz"},"maintainers":[{"name":"arunoda","email":"arunoda.susiripala@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/podda-1.2.1.tgz_1479004177443_0.6845768485218287"},"directories":{},"publish_time":1479004179528,"_cnpm_publish_time":1479004179528,"_hasShrinkwrap":false},"1.2.0":{"name":"podda","version":"1.2.0","description":"Simple Reactive DataStore for JavaScript","repository":{"type":"git","url":"git+https://github.com/arunoda/podda.git"},"license":"MIT","scripts":{"prepublish":". ./.scripts/prepublish.sh","lint":"eslint src","lintfix":"eslint src --fix","testonly":"mocha --require .scripts/mocha_runner src/**/tests/**/*.js","test":"npm run lint && npm run testonly","test-watch":"npm run testonly -- --watch --watch-extensions js"},"devDependencies":{"babel-cli":"^6.14.0","babel-core":"^6.14.0","babel-eslint":"^6.1.2","babel-loader":"^6.2.5","babel-plugin-transform-runtime":"^6.15.0","babel-polyfill":"^6.13.0","babel-preset-react-app":"^0.2.1","chai":"^3.5.0","eslint":"^3.6.0","eslint-config-airbnb":"^12.0.0","eslint-plugin-import":"^1.16.0","eslint-plugin-jsx-a11y":"^2.2.2","eslint-plugin-react":"^6.6.0","mocha":"^3.0.2","sinon":"^1.17.6"},"dependencies":{"babel-runtime":"^6.11.6","immutable":"^3.8.1"},"main":"dist/index.js","engines":{"npm":"^3.0.0"},"gitHead":"9d112fe3a72a59fa4c868a51713053d9747b9272","bugs":{"url":"https://github.com/arunoda/podda/issues"},"homepage":"https://github.com/arunoda/podda#readme","_id":"podda@1.2.0","_shasum":"9ad3e9eeb2d6d97441c974c33107229d75fdd1f5","_from":".","_npmVersion":"4.0.0","_nodeVersion":"6.6.0","_npmUser":{"name":"arunoda","email":"arunoda.susiripala@gmail.com"},"dist":{"shasum":"9ad3e9eeb2d6d97441c974c33107229d75fdd1f5","size":31170,"noattachment":false,"key":"/podda/-/podda-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/podda/download/podda-1.2.0.tgz"},"maintainers":[{"name":"arunoda","email":"arunoda.susiripala@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/podda-1.2.0.tgz_1478993786369_0.024087983882054687"},"directories":{},"publish_time":1478993786597,"_cnpm_publish_time":1478993786597,"_hasShrinkwrap":false},"1.1.0":{"name":"podda","version":"1.1.0","description":"Simple Reactive DataStore for JavaScript","repository":{"type":"git","url":"git+https://github.com/arunoda/podda.git"},"license":"MIT","scripts":{"prepublish":". ./.scripts/prepublish.sh","lint":"eslint src","lintfix":"eslint src --fix","testonly":"mocha --require .scripts/mocha_runner src/**/tests/**/*.js","test":"npm run lint && npm run testonly","test-watch":"npm run testonly -- --watch --watch-extensions js"},"devDependencies":{"babel-cli":"^6.14.0","babel-core":"^6.14.0","babel-eslint":"^6.1.2","babel-loader":"^6.2.5","babel-plugin-transform-runtime":"^6.15.0","babel-polyfill":"^6.13.0","babel-preset-react-app":"^0.2.1","chai":"^3.5.0","eslint":"^3.6.0","eslint-config-airbnb":"^12.0.0","eslint-plugin-import":"^1.16.0","eslint-plugin-jsx-a11y":"^2.2.2","mocha":"^3.0.2","sinon":"^1.17.6"},"dependencies":{"babel-runtime":"^6.11.6","eslint-plugin-react":"^6.6.0"},"main":"dist/index.js","engines":{"npm":"^3.0.0"},"gitHead":"02528e530268bcc65e9b2d6c4ac11f06570bc99d","bugs":{"url":"https://github.com/arunoda/podda/issues"},"homepage":"https://github.com/arunoda/podda#readme","_id":"podda@1.1.0","_shasum":"80a72cd6abff80193aa7eec2d9740ce5386ffe11","_from":".","_npmVersion":"4.0.0","_nodeVersion":"6.6.0","_npmUser":{"name":"arunoda","email":"arunoda.susiripala@gmail.com"},"dist":{"shasum":"80a72cd6abff80193aa7eec2d9740ce5386ffe11","size":30303,"noattachment":false,"key":"/podda/-/podda-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/podda/download/podda-1.1.0.tgz"},"maintainers":[{"name":"arunoda","email":"arunoda.susiripala@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/podda-1.1.0.tgz_1478600548148_0.5384200024418533"},"directories":{},"publish_time":1478600548389,"_cnpm_publish_time":1478600548389,"_hasShrinkwrap":false},"1.0.0":{"name":"podda","version":"1.0.0","description":"Simple Reactive DataStore for JavaScript","repository":{"type":"git","url":"git+https://github.com/arunoda/podda.git"},"license":"MIT","scripts":{"prepublish":". ./.scripts/prepublish.sh","lint":"eslint src","lintfix":"eslint src --fix","testonly":"mocha --require .scripts/mocha_runner src/**/tests/**/*.js","test":"npm run lint && npm run testonly","test-watch":"npm run testonly -- --watch --watch-extensions js"},"devDependencies":{"babel-cli":"^6.14.0","babel-core":"^6.14.0","babel-eslint":"^6.1.2","babel-loader":"^6.2.5","babel-plugin-transform-runtime":"^6.15.0","babel-polyfill":"^6.13.0","babel-preset-react-app":"^0.2.1","chai":"^3.5.0","eslint":"^3.6.0","eslint-config-airbnb":"^12.0.0","eslint-plugin-import":"^1.16.0","eslint-plugin-jsx-a11y":"^2.2.2","mocha":"^3.0.2","sinon":"^1.17.6"},"dependencies":{"babel-runtime":"^6.11.6","eslint-plugin-react":"^6.6.0"},"main":"dist/index.js","engines":{"npm":"^3.0.0"},"gitHead":"876f4ef2cd6ef76013144fe9f4cd05770329d0f4","bugs":{"url":"https://github.com/arunoda/podda/issues"},"homepage":"https://github.com/arunoda/podda#readme","_id":"podda@1.0.0","_shasum":"2beca95a0f07fded000c1feb5c8693182775b23f","_from":".","_npmVersion":"4.0.0","_nodeVersion":"6.6.0","_npmUser":{"name":"arunoda","email":"arunoda.susiripala@gmail.com"},"dist":{"shasum":"2beca95a0f07fded000c1feb5c8693182775b23f","size":30140,"noattachment":false,"key":"/podda/-/podda-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/podda/download/podda-1.0.0.tgz"},"maintainers":[{"name":"arunoda","email":"arunoda.susiripala@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/podda-1.0.0.tgz_1478598597760_0.05649993312545121"},"directories":{},"publish_time":1478598597996,"_cnpm_publish_time":1478598597996,"_hasShrinkwrap":false}},"readme":"# Podda\n\nSimple Reactive DataStore for JavaScript.\n\nThis is a pure JavaScript in-memory key value store for your Single Page App.(SPA)\nYou can think this as a simple key value store with an event emitter.\n\nThis works [pretty well with React](#using-with-react) (as an simple substitute for Redux/MobX), but works with anything in JavaScript.\n\n## TOC\n<!-- TOC depthFrom:2 depthTo:2 withLinks:1 updateOnSave:0 orderedList:0 -->\n\n- [Installation](#installation)\n- [Sample Usage](#sample-usage)\n- [API](#api)\n- [Using with React](#using-with-react)\n\n<!-- /TOC -->\n\n## Installation\n\n```js\nnpm install --save podda\n```\n\n## Sample Usage\n\nLet's subscribe to the data store and set an item.\n\n```js\nimport Podda from 'podda';\n\nconst defaults = { 'race': 'Human' };\nconst store = new Podda(defaults);\n\n// Subscribe for changes\nconst stopSubscription = store.subscribe((data) => {\n  console.log('Data:', data);\n});\n\n// Set some items.\nstore.set('name', 'Arunoda'); // logs => Data: { name: 'Arunoda' }\nstore.set('age', 99); // logs => Data: { name: 'Arunoda', age: 99 }\n\n// stop the subscription\nstopSubscription();\nstore.set('city', 'Colombo'); // logs nothing.\n```\n\n**[Play with this example](#podda)**\n\n## API\n\nAssume we've an instance of Podda called store as defined follows:\n\n```js\nconst store = new Podda();\n```\n\n### set\n\nSet a value. Value could be anything which can be serialize to JSON.\n\n```js\nstore.set('key', 'value');\n```\n\n### get\n\nGet a value by the give key.\n\n```js\nstore.get('key');\n```\n\n### update\n\nUpdate multiple entries of the store at once. While updating, you could accept the current state of the store as well.\n\n```js\nstore.update(function(state) {\n  return {\n    newField: 10,\n    existingField: !Boolean(existingField)\n  };\n});\n```\n\n### getAll\n\nGet all the key values pairs in the store as a map.\n\n```js\nstore.getAll();\n```\n\n### subscribe\n\nSubscribe for the store and get an snapshot of the data of the whole store.\nRegistered callback will be fired for everything you set something to the store.\n\n```js\nconst stop = store.subscribe((data) => {\n  console.log('Data:', data);\n});\n\n// Stop the subscription when needed\nstop();\n```\n\nCall to this method return a function where you can use that to stop the subscription.\n\n### watch\n\nVery similar to subscribe but watch a given key instead of the all keys.\n\n```js\nconst stop = store.watch('name', (name) => {\n  console.log('Name is:', name);\n});\n\nstore.set('name', 'Arunoda'); // logs => Name is: Arunoda\nstore.set('age', 99); // logs nothing.\n```\n\n### watchFor\n\nVery similar to watch but watch for the value of the key as well.\n\n```js\nconst stop = store.watchFor('name', 'Arunoda', (name) => {\n  console.log('Name is:', name);\n});\n\nstore.set('name', 'Arunoda'); // logs => Name is: Arunoda\nstore.set('name', 'Matt'); // logs nothing\n```\n\n### fire\n\nThis will be pretty useful with the `watch` and `watchFor` APIs. You could simply fire those callback, without setting an item to the store. Hence, this has no effect on the `subscribe`.\n\n```js\nconst stop = store.watch('name', (name) => {\n  console.log('Name is:', name);\n});\n\nstore.set('name', 'Arunoda'); // logs => Name is: Arunoda\nstore.fire('name', 'Matt'); // logs => Name is: Matt\nconsole.log(store.get('name')) // logs => Arunoda\n```\n\n### registerAPI\n\nWith this, you'll be able to add new features to the store.\nFor an example, let's say we are using toggle functionality in our store a lot. So, we can add an API for that like this:\n\n```js\nstore.registerAPI('toggle', (store, key) => {\n  store.set(key, !store.get(key));\n  return store.get(key);\n});\n\n// Then we can use it like this:\nconsole.log('Toggled value for lights is:', store.toggle('lights'));\n```\n\n## Using with React\n\nIn order to use this with React, you need to get help from a data container. [React Komposer](https://github.com/arunoda/react-komposer) is an ideal tool for that.\n\nHave a look at [this example app](http://www.webpackbin.com/EJgu0ne-z).\n","_attachments":{},"homepage":"https://github.com/arunoda/podda#readme","bugs":{"url":"https://github.com/arunoda/podda/issues"},"license":"MIT"}