{"_id":"@storybook/podda","_rev":"27-1a6b73499d882da714bf50ad4a0bc221","name":"@storybook/podda","dist-tags":{"latest":"1.2.3"},"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":{"integrity":"sha512-g7dsdsn50AhlGZ8iIDKdF8bi7Am++iFOq+QN+hNKz3FvgLuf8Dz+mpC/BFl90eE9bEYxXqXKeMf87399Ec5Qhw==","shasum":"53c4a1a3f8c7bbd5755dff5c34576fd1af9d38ba","tarball":"https://registry.npmjs.org/@storybook/podda/-/podda-1.2.3.tgz","fileCount":14,"unpackedSize":110416,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAfqwlCwQzn6GUfNrIB2tYTVVAWLXawmey+881DX9rHkAiEA5p2cL1zlDxUqAgkIsC9q+/u2J9Z86XpU+i/B4qP6R4o="}]},"maintainers":[{"name":"aaronmcadam","email":"aaron@aaronmcadam.com"},{"name":"alexandrebodin","email":"bodin.alex@gmail.com"},{"name":"arunoda","email":"arunoda.susiripala@gmail.com"},{"name":"danielduan","email":"dduan@yahoo.com"},{"name":"hypnosphi","email":"talpa@yandex.ru"},{"name":"igor-dv","email":"davydkin.igor@gmail.com"},{"name":"mnmtanish","email":"mnmtanish@gmail.com"},{"name":"mthuret","email":"mlthutrix@gmail.com"},{"name":"ndelangen","email":"ndelangen@me.com"},{"name":"shilman","email":"michael@lab80.co"},{"name":"tvs","email":"teije-vs@hotmail.com"},{"name":"usulpro","email":"regx@usul.su"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/podda_1.2.3_1519087414217_0.5088261185805243"},"_hasShrinkwrap":false}},"time":{"created":"2018-02-20T00:43:34.143Z","1.2.3":"2018-02-20T00:43:34.295Z","modified":"2022-04-07T02:52:11.443Z"},"maintainers":[],"description":"Simple Reactive DataStore for JavaScript","homepage":"https://github.com/arunoda/podda#readme","repository":{"type":"git","url":"git+https://github.com/arunoda/podda.git"},"bugs":{"url":"https://github.com/arunoda/podda/issues"},"license":"MIT","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","readmeFilename":"README.md"}