{"_id":"@abhinavzspace/redux-pouchdb-plus","_rev":"6-0c21afcba4ee66dbc0de1748a924ac1e","name":"@abhinavzspace/redux-pouchdb-plus","description":"Synchronize Redux store with PouchDB to have a persistent store.","dist-tags":{"latest":"0.8.4"},"versions":{"0.8.1":{"name":"@abhinavzspace/redux-pouchdb-plus","version":"0.8.1","description":"Synchronize Redux store with PouchDB to have a persistent store.","main":"src/index.js","scripts":{"prepublish":"rimraf lib && babel src --out-dir lib","test":"babel-tape-runner tests/*.js","deploy:patch":"npm version patch; npm run deploy","deploy:minor":"npm version minor; npm run deploy","deploy:major":"npm version major; npm run deploy","deploy":"git push origin master; npm publish"},"files":["src/","package.json","README.md"],"repository":{"type":"git","url":"git+https://github.com/medihack/redux-pouchdb-plus.git"},"keywords":["redux","react","pouchdb"],"author":{"name":"Kai Schlamp"},"license":"MIT","bugs":{"url":"https://github.com/medihack/redux-pouchdb-plus/issues"},"homepage":"https://github.com/medihack/redux-pouchdb-plus#readme","devDependencies":{"babel-cli":"^6.4.5","babel-core":"^6.4.5","babel-preset-es2015":"^6.3.13","babel-tape-runner":"^2.0.0","memdown":"^1.1.1","redux":"^3.0.5","rimraf":"^2.5.1","tape":"^4.4.0","timeout-then":"^1.0.0"},"peerDependencies":{"pouchdb":"^6.0.0","immutable":"^3.7.6"},"dependencies":{"lodash.clonedeep":"^4.1.0","lodash.isequal":"^4.0.0","node-uuid":"^1.4.7","transit-immutable-js":"^0.5.2","transit-js":"^0.8.846"},"gitHead":"5185a1d0f13b35edbfa7b9d615b7262548426c7a","_id":"@abhinavzspace/redux-pouchdb-plus@0.8.1","_shasum":"be9fe2a1d01a22e5068fbb69154b302b7a0acc73","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.7.0","_npmUser":{"name":"abhinavzspace","email":"abhinavzspace@gmail.com"},"dist":{"shasum":"be9fe2a1d01a22e5068fbb69154b302b7a0acc73","tarball":"https://registry.npmjs.org/@abhinavzspace/redux-pouchdb-plus/-/redux-pouchdb-plus-0.8.1.tgz","integrity":"sha512-ORfGDi8FwGPtdkO4/WaQLBRSi44wQuourQ4Vg5/SCzA+otgJjZmE5QA1/eZOjf9QX3PsKkFaIrYcwP0HOt0IiQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICGnFCtaCplbueOoL+OSiEDt9bm6CCUyMIB4ozcIiSDNAiEAwIX7iaEM4qyIoa90gEdur7pBPDMTg+OtAeqqzbioegk="}]},"maintainers":[{"name":"abhinavzspace","email":"abhinavzspace@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/redux-pouchdb-plus-0.8.1.tgz_1475588038344_0.23870210838504136"}},"0.8.2":{"name":"@abhinavzspace/redux-pouchdb-plus","version":"0.8.2","description":"Synchronize Redux store with PouchDB to have a persistent store.","main":"lib/index.js","scripts":{"prepublish":"rimraf lib && babel src --out-dir lib","test":"babel-tape-runner tests/*.js","deploy:patch":"npm version patch; npm run deploy","deploy:minor":"npm version minor; npm run deploy","deploy:major":"npm version major; npm run deploy","deploy":"git push origin master; npm publish"},"files":["lib/","package.json","README.md"],"repository":{"type":"git","url":"git+https://github.com/medihack/redux-pouchdb-plus.git"},"keywords":["redux","react","pouchdb"],"author":{"name":"Kai Schlamp"},"license":"MIT","bugs":{"url":"https://github.com/medihack/redux-pouchdb-plus/issues"},"homepage":"https://github.com/medihack/redux-pouchdb-plus#readme","devDependencies":{"babel-cli":"^6.4.5","babel-core":"^6.4.5","babel-preset-es2015":"^6.3.13","babel-tape-runner":"^2.0.0","memdown":"^1.1.1","redux":"^3.0.5","rimraf":"^2.5.1","tape":"^4.4.0","timeout-then":"^1.0.0"},"peerDependencies":{"pouchdb":"^6.0.6","immutable":"^3.7.6"},"dependencies":{"lodash.clonedeep":"^4.1.0","lodash.isequal":"^4.0.0","node-uuid":"^1.4.7","transit-immutable-js":"^0.5.2","transit-js":"^0.8.846"},"gitHead":"b070e028bf5bbe0186a20a6017a44042828cdc9b","_id":"@abhinavzspace/redux-pouchdb-plus@0.8.2","_shasum":"b7c4e363409950d1432973f673677e4aea49fb08","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.7.0","_npmUser":{"name":"abhinavzspace","email":"abhinavzspace@gmail.com"},"dist":{"shasum":"b7c4e363409950d1432973f673677e4aea49fb08","tarball":"https://registry.npmjs.org/@abhinavzspace/redux-pouchdb-plus/-/redux-pouchdb-plus-0.8.2.tgz","integrity":"sha512-Y4/yMBAtW1xZKBVZehvsflX4WBrk7DPyUEHedhOZrPkj8pVHG+gMUmW7B2ZAPFLw8iHDwa3JAouQHiEGk3QGbA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCdVx2ie11FJxftL3xDBH11vbXOwCotCtEFLWYv9hsRgAIhAN2MgwCKYOVk6GEO8Z7eToZC0WPX3guX16J4M/VE8rUi"}]},"maintainers":[{"name":"abhinavzspace","email":"abhinavzspace@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/redux-pouchdb-plus-0.8.2.tgz_1475770545912_0.1611964979674667"}},"0.8.3":{"name":"@abhinavzspace/redux-pouchdb-plus","version":"0.8.3","description":"Synchronize Redux store with PouchDB to have a persistent store.","main":"lib/index.js","scripts":{"prepublish":"rimraf lib && babel src --out-dir lib","test":"babel-tape-runner tests/*.js","deploy:patch":"npm version patch; npm run deploy","deploy:minor":"npm version minor; npm run deploy","deploy:major":"npm version major; npm run deploy","deploy":"git push origin master; npm publish"},"files":["lib/","package.json","README.md"],"repository":{"type":"git","url":"git+https://github.com/medihack/redux-pouchdb-plus.git"},"keywords":["redux","react","pouchdb"],"author":{"name":"Kai Schlamp"},"license":"MIT","bugs":{"url":"https://github.com/medihack/redux-pouchdb-plus/issues"},"homepage":"https://github.com/medihack/redux-pouchdb-plus#readme","devDependencies":{"babel-cli":"^6.4.5","babel-core":"^6.4.5","babel-preset-es2015":"^6.3.13","babel-tape-runner":"^2.0.0","memdown":"^1.1.1","redux":"^3.0.5","rimraf":"^2.5.1","tape":"^4.4.0","timeout-then":"^1.0.0"},"peerDependencies":{"pouchdb":"^6.0.6","immutable":"^3.7.6"},"dependencies":{"lodash.clonedeep":"^4.1.0","lodash.isequal":"^4.0.0","node-uuid":"^1.4.7","transit-immutable-js":"^0.5.2","transit-js":"^0.8.846"},"gitHead":"ad0b7a7fae281e25a373310156cea13d89dc1250","_id":"@abhinavzspace/redux-pouchdb-plus@0.8.3","_shasum":"97b87b6f6f4ab76299b34a9aa7b69f9188e00dbe","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.7.0","_npmUser":{"name":"abhinavzspace","email":"abhinavzspace@gmail.com"},"dist":{"shasum":"97b87b6f6f4ab76299b34a9aa7b69f9188e00dbe","tarball":"https://registry.npmjs.org/@abhinavzspace/redux-pouchdb-plus/-/redux-pouchdb-plus-0.8.3.tgz","integrity":"sha512-Fn2nqdciXmgwVtY6vlNcb8C68zfEpM6KfCIOX6cz/P5UPv0pV2gHJBD19Zertd5/64zfxZCwFR2OD1qiyW3Mpw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDZO6GEQG8inZZOthADbzedefpSEGweD606g57VOb37+AIgJCW2aETYwZ5l/fzKmW9Uex0WlQky/9i4fe4zPqufxxg="}]},"maintainers":[{"name":"abhinavzspace","email":"abhinavzspace@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/redux-pouchdb-plus-0.8.3.tgz_1475841412063_0.8528947660233825"}},"0.8.4":{"name":"@abhinavzspace/redux-pouchdb-plus","version":"0.8.4","description":"Synchronize Redux store with PouchDB to have a persistent store.","main":"lib/index.js","scripts":{"prepublish":"rimraf lib && babel src --out-dir lib","test":"babel-tape-runner tests/*.js","deploy:patch":"npm version patch; npm run deploy","deploy:minor":"npm version minor; npm run deploy","deploy:major":"npm version major; npm run deploy","deploy":"git push origin master; npm publish"},"files":["lib/","package.json","README.md"],"repository":{"type":"git","url":"git+https://github.com/medihack/redux-pouchdb-plus.git"},"keywords":["redux","react","pouchdb"],"author":{"name":"Kai Schlamp"},"license":"MIT","bugs":{"url":"https://github.com/medihack/redux-pouchdb-plus/issues"},"homepage":"https://github.com/medihack/redux-pouchdb-plus#readme","devDependencies":{"babel-cli":"^6.4.5","babel-core":"^6.4.5","babel-preset-es2015":"^6.3.13","babel-tape-runner":"^2.0.0","memdown":"^1.1.1","redux":"^3.0.5","rimraf":"^2.5.1","tape":"^4.4.0","timeout-then":"^1.0.0"},"peerDependencies":{"pouchdb":"^6.0.6","immutable":"^3.7.6"},"dependencies":{"lodash.clonedeep":"^4.1.0","lodash.isequal":"^4.0.0","node-uuid":"^1.4.7","transit-immutable-js":"^0.5.2","transit-js":"^0.8.846"},"gitHead":"1bf31f4b6b80f1c5ce3016e91d989ad8273e54ae","_id":"@abhinavzspace/redux-pouchdb-plus@0.8.4","_shasum":"ec849eafc75a640f1a689ac15994849613a7e274","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.7.0","_npmUser":{"name":"abhinavzspace","email":"abhinavzspace@gmail.com"},"dist":{"shasum":"ec849eafc75a640f1a689ac15994849613a7e274","tarball":"https://registry.npmjs.org/@abhinavzspace/redux-pouchdb-plus/-/redux-pouchdb-plus-0.8.4.tgz","integrity":"sha512-I8DgRLUdlRM+CejQCBV0AAQzW5XOd/XPk7lK87V1wsfDZ6SMIAYaL4bFdLDNbu1CTOt14tSsH/b7f3auoVBa6g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAMBUWIwdmK8+z4ohe0Tqrqk3yE+Xw2fuFhtxIrmFMrrAiEA3U1gZQEcWLJxBiUwqQTdhxWzatOhJhqAvZYlQVDUifY="}]},"maintainers":[{"name":"abhinavzspace","email":"abhinavzspace@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/redux-pouchdb-plus-0.8.4.tgz_1476035176514_0.37192070577293634"}}},"readme":"# Redux PouchDB Plus\n\n## About\n\n**Redux PouchDB Plus** synchronizes a [Redux](rackt.github.io/redux) store with a [PouchDB](http://pouchdb.com/) database.\n\nThis code is heavily inspired (and some code reused) by Vicente de Alencar's [redux-pouchdb](https://github.com/vicentedealencar/redux-pouchdb).\nSo all Kudos to him. The rewrite was necessary to allow the following extras:\n\n- Have different Pouch databases for different reducers.\n- Allow to switch databases dynamically.\n- Support for [Immutable](https://facebook.github.io/immutable-js/) states beside pure Javascript types.\n- Provide several callbacks (when initialization and database access happens).\n\nThe code is quite well tested using [tape](https://github.com/substack/tape).\n\n## Usage\n\n### General setup\n\nThe reducers you wish to persist should be enhanced with this higher order reducer (`persistentReducer`).\n\n``` js\nimport { persistentReducer } from 'redux-pouchdb-plus';\n\nconst counter = (state = {count: 0}, action) => {\n  switch(action.type) {\n  case INCREMENT:\n    return { count: state.count + 1 };\n  case DECREMENT:\n    return { count: state.count - 1 };\n  default:\n    return state;\n  }\n};\n\nconst finalReducer = persistentReducer(counter);\n```\n\nCompose a store enhancer (`persistentStore`) with other enhancers in order to initialize the persistence.\n\n``` js\nimport { persistentStore } from 'redux-pouchdb-plus';\n\nconst db = new PouchDB('dbname');\n\n//optional\nconst applyMiddlewares = applyMiddleware(\n  thunkMiddleware,\n  loggerMiddleware\n);\n\nconst createStoreWithMiddleware = compose(\n  applyMiddlewares,\n  persistentStore({db})\n)(createStore);\n\nconst store = createStoreWithMiddleware(finalReducer, initialState);\n```\n\nYou may also provide a specific database for this reducer (it is prioritized over\nthe provided database to the store).\n\n```js\nconst db2 = new PouchDB('another_dbname');\nconst finalReducer = persistentReducer(counter, {db: db2});\n```\n\n### Switching databases during runtime\n\nYou may also provide a function that return a database connector instead of the\nconnector itself. This makes it possible to switch databases dynamically during runtime.\n\n```js\nimport { reinit } from 'redux-pouchdb-plus';\n\nlet dbChoice = 1;\nconst db = (reducerName, store, additionalOptions) => {\n  if (dbChoice === 1)\n    return new PouchDB('dbname1');\n  else\n    return new PouchDB('dbname2');\n}\n\n// uses 'dbname1' database\nconst finalReducer = persistentReducer(counter, {db});\n\n// switch to 'dbname2' database\ndbChoice = 2;\n// reinitialize reducer counter\nstore.dispatch(reinit('counter'));\n// reinitialize all reducers\nstore.dispatch(reinit());\n```\n\n### Check if database is in sync\n\nWith the `inSync` method you can check if all state changes of persistent\nreducers are saved to the database or if there is some saving in progress.\n\n```js\nimport { inSync } from 'redux-pouchdb-plus';\n\nif (inSync()) {\n  // do something if the reducer states and the database are in sync\n}\n```\n\n### Use Immutable js states\n\nYou can use [Immutable.js](https://facebook.github.io/immutable-js/) states\nin your reducers. This works automatically if the **initial state is an\nImmutable.js data type**.\n\n```js\n// automatically serializes Immutable.js data types to PouchDB\n// when the initial state is an Immutable\nconst counter = (state = Immutable.Map({count: 0}), action) => {\n  switch(action.type) {\n  case INCREMENT:\n    return { count: state.count + 1 };\n  case DECREMENT:\n    return { count: state.count - 1 };\n  default:\n    return state;\n  }\n};\n\nconst finalReducer = persistentReducer(counter);\n```\n\nIt is even possible to mix immutable and plain Javascript data\nas internally [transit-immutable-js](https://github.com/glenjamin/transit-immutable-js)\nis used for serialization to the database. Just make sure that the top\nstate container of the reducer is an immutable.\n\n```js\n// this is a valid state\nImmutable.Map({x: [1, 2, 3]});\n\n// this will open the doors to hell\n[1, 2, Immutable.Map({x: 3})];\n```\n\n### Provided callback functions\n\nYou may provide the following callback functions as addition options to\n`persistentReducer` or `persistentReducer`:\n\n```js\n// example for persistentStore, but works the same for persistentReducer function.\npersistentStore(counter, {\n  db,\n  onInit: (reducerName, reducerState, store) => {\n    // Called when this reducer was initialized\n    // (the state was loaded from or saved to the\n    // database for the first time or after a reinit action).\n  },\n  onUpdate: (reducerName, reducerState, store) => {\n    // Called when the state of reducer was updated with\n    // data from the database.\n    // Cave! The store still contains the state before\n    // the updated reducer state was applied to it.\n  },\n  onSave: (reducerName, reducerState, store) => {\n    // Called every time the state of this reducer was\n    // saved to the database.\n  }\n});\n```\n\nAdditionally you may provide an `onReady` callback on the store that is called\nevery time all persistent recuders finished the initialization.\n\n```js\npersistentStore(counter, {\n  db,\n  onReady: (store) => {\n    // Called when all reducers are initialized (also after\n    // a reinit for all reducers is finished).\n  }\n}\n```\n\n## Notes\n\nThe current behavior is to have one document for each persisted reducer that looks like:\n\n``` js\n{\n  _id: 'reducerName', // the name the reducer function\n  state: {}|[], // the state of the reducer\n  _rev: '' // pouchdb keeps track of the revisions\n}\n```\n","maintainers":[{"name":"abhinavzspace","email":"abhinavzspace@gmail.com"}],"time":{"modified":"2022-06-12T14:14:28.903Z","created":"2016-10-04T13:34:01.303Z","0.8.1":"2016-10-04T13:34:01.303Z","0.8.2":"2016-10-06T16:15:46.166Z","0.8.3":"2016-10-07T11:56:55.796Z","0.8.4":"2016-10-09T17:46:16.746Z"},"homepage":"https://github.com/medihack/redux-pouchdb-plus#readme","keywords":["redux","react","pouchdb"],"repository":{"type":"git","url":"git+https://github.com/medihack/redux-pouchdb-plus.git"},"author":{"name":"Kai Schlamp"},"bugs":{"url":"https://github.com/medihack/redux-pouchdb-plus/issues"},"license":"MIT","readmeFilename":"README.md"}