{"_id":"@storybook/podda","_rev":"471388","name":"@storybook/podda","description":"Simple Reactive DataStore for JavaScript","dist-tags":{"latest":"1.2.3"},"maintainers":[{"name":"amalik2","email":"ahnmalik2@gmail.com"},{"name":"ghengeveld","email":"info@ghengeveld.nl"},{"name":"kylesuss","email":"susskyle@gmail.com"},{"name":"mrmckeb","email":"mrmckeb.npm@outlook.com"},{"name":"pago","email":"patrick@pagosoft.com"},{"name":"phated","email":"blaine.bublitz@gmail.com"},{"name":"usulpro","email":"regx@usul.su"},{"name":"winkervsbecks","email":"varunvachhar@gmail.com"}],"time":{"modified":"2021-08-05T08:19:52.000Z","created":"2018-02-20T00:43:34.295Z","1.2.3":"2018-02-20T00:43:34.295Z"},"users":{},"repository":{"type":"git","url":"git+https://github.com/arunoda/podda.git"},"versions":{"1.2.3":{"name":"@storybook/podda","version":"1.2.3","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":"3289f6720880aec0e94402bbf8f5eb7f9ec0f417","bugs":{"url":"https://github.com/arunoda/podda/issues"},"homepage":"https://github.com/arunoda/podda#readme","_id":"@storybook/podda@1.2.3","_npmVersion":"5.5.1","_nodeVersion":"8.8.1","_npmUser":{"name":"danielduan","email":"dduan@yahoo.com"},"dist":{"shasum":"53c4a1a3f8c7bbd5755dff5c34576fd1af9d38ba","size":31573,"noattachment":false,"key":"/@storybook/podda/-/@storybook/podda-1.2.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/@storybook/podda/download/@storybook/podda-1.2.3.tgz"},"maintainers":[{"name":"amalik2","email":"ahnmalik2@gmail.com"},{"name":"ghengeveld","email":"info@ghengeveld.nl"},{"name":"kylesuss","email":"susskyle@gmail.com"},{"name":"mrmckeb","email":"mrmckeb.npm@outlook.com"},{"name":"pago","email":"patrick@pagosoft.com"},{"name":"phated","email":"blaine.bublitz@gmail.com"},{"name":"usulpro","email":"regx@usul.su"},{"name":"winkervsbecks","email":"varunvachhar@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/podda_1.2.3_1519087414217_0.5088261185805243"},"_hasShrinkwrap":false,"publish_time":1519087414295,"_cnpm_publish_time":1519087414295}},"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](http://www.webpackbin.com/4ynVqTQPM)**\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"}