{"_id":"@bilgorajskim/ra-realtime","_rev":"3-c5301b7fa6198a497725e8fa68933b43","name":"@bilgorajskim/ra-realtime","dist-tags":{"latest":"2.1.0-2"},"versions":{"2.1.0-0":{"name":"@bilgorajskim/ra-realtime","version":"2.1.0-0","description":"A saga enabling realtime updates for react-admin","main":"./lib/index.js","repository":{"type":"git","url":"git+https://github.com/marmelab/react-admin.git"},"bugs":{"url":"https://github.com/marmelab/react-admin/issues"},"homepage":"https://github.com/marmelab/react-admin#readme","authors":["Gildas Garcia"],"keywords":["reactjs","react","@bilgorajskim/react-admin","admin-on-rest","rest","realtime"],"license":"MIT","dependencies":{"lodash":"~4.17.5"},"peerDependencies":{"@bilgorajskim/react-admin":"^2.0.4","react-router":"~4.2.0","react-router-redux":"~5.0.0-alpha.9","redux-saga":"~0.16.0"},"devDependencies":{"@bilgorajskim/react-admin":"^2.1.0-0","react-router":"~4.2.0","react-router-redux":"~5.0.0-alpha.9","redux-saga":"~0.16.0"},"publishConfig":{"access":"public"},"_id":"@bilgorajskim/ra-realtime@2.1.0-0","_npmVersion":"6.1.0","_nodeVersion":"10.4.0","_npmUser":{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"},"dist":{"integrity":"sha512-qxFHavahbaDGirC37+EnvwhmsDKo0ntoQib37o6meCV7fXYkYgRfmSEYS3tOnrJIBXsCXOTpBWrXYP+3yvzZSg==","shasum":"46b5504457f02137846c89b2152f6380cb8f99c8","tarball":"https://registry.npmjs.org/@bilgorajskim/ra-realtime/-/ra-realtime-2.1.0-0.tgz","fileCount":9,"unpackedSize":9720,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbNwQiCRA9TVsSAnZWagAAhvAP/itusoEmhaj7O4IsUfgs\nsvqWNwHseKUkuc3w83iWSHIcD/P5iwJnJnNesBZBRpvjqTDlm8/Iwx0qAXvl\nHav3rbn3mxYt6HpvvP06M0BFpVEJ/koL6dmyvkEnKsSSsejGcWAZXAnKltey\nA95nKSXEo/OCMvv8kvw5kQLdn9pWwOG/eU0co0Q48ie+MeSq9C3B6Ngu75ii\nPX11CJcxoIH9gz/UnytWv9Dv6RVdaXR6XEpjOXJXEVcgrdSO7MIPqjonY6J2\nRcm1zSg2Gt5B+WyC6ceExXwgp1+ekBQ1jzKaEDBGh3AvUVFg4aBvojt4NsXh\njocK5ZmB1xv4AWNGEK3zWb8MEjhoUs0ptPn7xJTvPIDT5izGACeiQ315lT0F\nivLvbKHYxIoeTPcuhIVuEjtPchdq0xhuu4N27sNccVHytF16ABuFy7y+A8nn\nVYe6GLL37oiuxyJlKchdPTby9TtZ7S30a2sZwVcugCi31cGNGe/q23z6H4Tu\nWgIcct4KR3johEAltQobUcWnkTV1WTfTBRBBJV8tZ5HjMaKabw/fHWLKVixj\nP+W2z/+z3BTwu/ECk39l5Dn27sxD2yEdI9oApRtJIApAn9KLxxx1ZxjWeDUL\nCs9sQJNStLQWpn14AcjmLSojZhgSCQUmjzeLsY/WVrN75YvxbNZnglr7qC9+\nZScV\r\n=p5OI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHikN9ef9h53XEdh6i9MR16ysS8+Cugao5atjB8eRmgvAiEAsSIWXTUNsfBs12UgtxQEKncVVwPkwpckv2Kbtz7O1GM="}]},"maintainers":[{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ra-realtime_2.1.0-0_1530332194091_0.004202662163404813"},"_hasShrinkwrap":false},"2.1.0-1":{"name":"@bilgorajskim/ra-realtime","version":"2.1.0-1","description":"A saga enabling realtime updates for react-admin","main":"./lib/index.js","repository":{"type":"git","url":"git+https://github.com/marmelab/react-admin.git"},"bugs":{"url":"https://github.com/marmelab/react-admin/issues"},"homepage":"https://github.com/marmelab/react-admin#readme","authors":["Gildas Garcia"],"keywords":["reactjs","react","@bilgorajskim/react-admin","admin-on-rest","rest","realtime"],"license":"MIT","dependencies":{"lodash":"~4.17.5"},"peerDependencies":{"@bilgorajskim/react-admin":"^2.0.4","react-router":"~4.2.0","react-router-redux":"~5.0.0-alpha.9","redux-saga":"~0.16.0"},"devDependencies":{"@bilgorajskim/react-admin":"^2.1.0-1","react-router":"~4.2.0","react-router-redux":"~5.0.0-alpha.9","redux-saga":"~0.16.0"},"publishConfig":{"access":"public"},"_id":"@bilgorajskim/ra-realtime@2.1.0-1","_npmVersion":"6.1.0","_nodeVersion":"10.4.0","_npmUser":{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"},"dist":{"integrity":"sha512-21JhGjXZmLmTfz4Vwf3iAS5jBjbc3wCe21hJZGRaKLYbGAeSwYneGT+l4vkgGEPAkAVPUqgEzKL3BC0Mzqc28A==","shasum":"59cfd10f74b1afff8f28f7862f22951781f6c63e","tarball":"https://registry.npmjs.org/@bilgorajskim/ra-realtime/-/ra-realtime-2.1.0-1.tgz","fileCount":9,"unpackedSize":9720,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbNwX6CRA9TVsSAnZWagAANJoP/1Nb0g97SHXlz54aYezS\nF4mT7QE6OdOpkmF1IyOuUHJofIrKNo3EhBE9MopQOEffamdD5rDhgIhKmHGt\nXaA6eDt8dLhMwNIEN0uDVEmPbndlN5SogmBJX+KjPGolY54a/5OyjkFY8cGm\n0GxE/Re2WpN1LxWbWx0zcHBLOTpDhg8qjzIOwNqYNpZj4GKV1DNVI4GwFtMT\nQM63HO8fPeVD0KMOuCUsGgKfHZENJGkHUMo9Co1TGysXkrXTrzfaxqrYiZi2\nj2qSPUuEoSUvlixEXXSRhY0iLlluSO6pwz9q359KHeR0gbj3GyTRnC1Vm7Bi\na+DJqH4ytk3OECadDQH3lcC4RZ9p3Y3Asp25xji3o+6YK4JqZ3k/ymzzN414\njMOXcSAXHH++QjRWgFs+qeVj+QK9QyvipWmOpjEogUO8+Tegtz3QE7T3OQRe\numtfDmPtFc9/+yjc9MGXVQzPu1wneE+fLVRg/fdi9HlCdRuZsqLcCjVehxsm\nQb12d6DNRWEmv3sJu+f/QrQQ3acWjEWJaF4KN7JEssT45U3y6IqZA2/C/iSf\n8lIP9Sf+uvkHxvFs81XvVcodRHe92seAXKTXvh82vg6gsCUZ/b6aR+nLTH8C\n0skS6rbA2DhuXJ7TPE64eHqw20q3TZk9ATPDSJ7zV4cQiioLm1Uexgkraeye\nA7jL\r\n=dhxw\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCLVLN5mhny3PZpng7j7pFT2sZqpgf/U7Ov6Nm62JGcXAIgcarrKU5C/L+56PBpeIQGUvcGRagUViMwIYfpUAdTJD8="}]},"maintainers":[{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ra-realtime_2.1.0-1_1530332666618_0.38792622574201885"},"_hasShrinkwrap":false},"2.1.0-2":{"name":"@bilgorajskim/ra-realtime","version":"2.1.0-2","description":"A saga enabling realtime updates for react-admin","main":"./lib/index.js","repository":{"type":"git","url":"git+https://github.com/marmelab/react-admin.git"},"bugs":{"url":"https://github.com/marmelab/react-admin/issues"},"homepage":"https://github.com/marmelab/react-admin#readme","authors":["Gildas Garcia"],"keywords":["reactjs","react","@bilgorajskim/react-admin","admin-on-rest","rest","realtime"],"license":"MIT","dependencies":{"lodash":"~4.17.5"},"peerDependencies":{"@bilgorajskim/react-admin":"^2.0.4","react-router":"~4.2.0","react-router-redux":"~5.0.0-alpha.9","redux-saga":"~0.16.0"},"devDependencies":{"@bilgorajskim/react-admin":"^2.1.0-2","react-router":"~4.2.0","react-router-redux":"~5.0.0-alpha.9","redux-saga":"~0.16.0"},"publishConfig":{"access":"public"},"_id":"@bilgorajskim/ra-realtime@2.1.0-2","_npmVersion":"6.1.0","_nodeVersion":"10.4.0","_npmUser":{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"},"dist":{"integrity":"sha512-bGxFeaoIeBTH2ppnpqAQrxb/MyLWpHDYEUr9+y++E2kytYA5nN2MkB4YyVkD1FPGmq5ol7nbmuOVnpwHCrowbg==","shasum":"c5ff0c2e0c1e724fc9221dd7dc7d3e4a026d91d4","tarball":"https://registry.npmjs.org/@bilgorajskim/ra-realtime/-/ra-realtime-2.1.0-2.tgz","fileCount":9,"unpackedSize":9720,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbNwbXCRA9TVsSAnZWagAASNoQAIFp+HnQRvlVeDTFeGs8\n/vVhF42ujT4z1nnBUKeNqRrKEG26RNxfhf1EgXVT3WWnaM0gLSVKaU8nRT79\nE1cUsSG1UYjUHOTO3eScG35ccmpCp1iJ6luJpRA2IYvOlJB5YenvUTa2ilfI\n4vq0qqyBivYmER14xweKdcOHY8ChOAylp+EhkCvFPpb9303Ye5gzyVzxTjkk\nxP6dC8ObS6Lgt0XUlw8u/Hmp2PmBBoVsOEm9bCOGm5gRx8E/iYulzUxXUaa0\nGQgB6/NHkcmj1N9hJLvn2oC/hsHz6RjSWV4x6SN/804RNS1KLBdeZsT/3dF7\nsmahdqm0gAGY0ktwvfwOqpts9xXGvKk2QRXq6IQEC1a4f6rQIS4exu6TB1t+\n8OOguEZXXPoINT410TkbSctaZyesrIbKjDTfffTQVyFMUXk5ijgf7LPz3pYJ\ngAEtKeX4UCnL1yKEfj9YML5yK0NTpEmOUqW0/pwQ9BHeLAj5+mrXTZ6Z/nCs\nYYQlAXi0SKSEcWhLeVTs90ivnU8wUmhBX/ucXjMU+9xGMOeeIfOMbXUhuYIb\nLTkH618gUTkHD2gdf6CGJlVOC2OxUxiOsRSw9QwZUnLv6RlYzzTv6pbE4AUO\n0yR2IJjU0H3Jw2g5OjzugFeW7BCeqmHypMm+RB2BuvNRe2MMRbWyS6onjqHL\nttcv\r\n=RMPa\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC1Dkgm38VnPZ8dYCfSkh7W8Bi5W+KIStawtsiGlhlPBAIgWQBIQWjnd1PUAs4ewb4zgRVYgVCZPD2TGC3ddg63XNw="}]},"maintainers":[{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ra-realtime_2.1.0-2_1530332887564_0.2014021881057555"},"_hasShrinkwrap":false}},"time":{"created":"2018-06-30T04:16:33.849Z","2.1.0-0":"2018-06-30T04:16:34.201Z","modified":"2022-04-04T18:48:39.231Z","2.1.0-1":"2018-06-30T04:24:26.670Z","2.1.0-2":"2018-06-30T04:28:07.640Z"},"maintainers":[{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"}],"description":"A saga enabling realtime updates for react-admin","homepage":"https://github.com/marmelab/react-admin#readme","keywords":["reactjs","react","@bilgorajskim/react-admin","admin-on-rest","rest","realtime"],"repository":{"type":"git","url":"git+https://github.com/marmelab/react-admin.git"},"bugs":{"url":"https://github.com/marmelab/react-admin/issues"},"license":"MIT","readme":"# ra-realtime\n\nA custom saga enabling realtime update inside [react-admin](https://github.com/marmelab/react-admin/).\n\n## Installation\n\nInstall with:\n\n```sh\nnpm install --save ra-realtime\n```\n\nor\n\n```sh\nyarn add ra-realtime\n```\n\n## Usage\n\nDefine an `observeRequest` function which will be called by the realtime saga whenever a `CRUD_GET_LIST` or `CRUD_GET_ONE` fetch\nis triggered by react-admin ([documentation](https://marmelab.com/react-admin/DataProviders.html) about those).\n\nThis function will be called with the following parameters:\n\n- `fetchType`: either `CRUD_GET_LIST` or `CRUD_GET_ONE`\n- `resource`: the resource's name\n- `params`: the fetch parameters\n  - for `CRUD_GET_LIST`: `{ pagination: { page: {int} , perPage: {int} }, sort: { field: {string}, order: {string} }, filter: {Object} }`\n  - for `CRUD_GET_ONE`: `{ id: {mixed} }`\n\nThis function must return an object with a `subscribe` method which will be called with an `observer`. If it returns `null`, the query won't be updated automatically. This allows you to decide which query should be updated in real time.\n\nThe `observer` have the following methods:\n\n- `next(data)`: Call this method each time new data is received so that the react-admin views are updated.\n- `complete()`: Call this method to indicates this subscription won't receive any new data.\n- `error(error)`: Call this method when an error occurs.\n\nThe `subscribe` method must return a `subscription` object. The `subscription` object must have an `unsubscribe` method which will be called by the realtime saga when the query will not need to be observed anymore. This will happen each time the current route change and will give you the opportunity to clean up related sockets, apollo observable queries, etc. When called and after you cleaned up whatever needed cleaning, you **must** call the `observer.complete` method so that the realtime saga is notified about it.\n\nHere is a very naive example using an interval to fetch data every 5 seconds:\n\n```js\n// In createRealtimeSaga.js\nimport realtimeSaga from 'ra-realtime';\n\nconst observeRequest = dataProvider => (type, resource, params) => {\n    // Filtering so that only posts are updated in real time\n    if (resource !== 'posts') return;\n\n    // Use your apollo client methods here or sockets or whatever else including the following very naive polling mechanism\n    return {\n        subscribe(observer) {\n            const intervalId = setInterval(() => {\n                dataProvider(type, resource, params)\n                    .then(results => observer.next(results)) // New data received, notify the observer\n                    .catch(error => observer.error(error)); // Ouch, an error occured, notify the observer\n            }, 5000);\n\n            const subscription = {\n                unsubscribe() {\n                    // Clean up after ourselves\n                    clearInterval(intervalId);\n                    // Notify the saga that we cleaned up everything\n                    observer.complete();\n                }\n            };\n\n            return subscription;\n        },\n    };\n};\n\nexport default dataProvider => realtimeSaga(observeRequest(dataProvider));\n```\n","readmeFilename":"README.md"}