{"id":19128796,"url":"https://github.com/peerlibrary/meteor-subscription-data","last_synced_at":"2025-05-06T00:10:41.028Z","repository":{"id":68281877,"uuid":"48331604","full_name":"peerlibrary/meteor-subscription-data","owner":"peerlibrary","description":"Reactive and shared subscription data context","archived":false,"fork":false,"pushed_at":"2019-09-20T06:31:55.000Z","size":23,"stargazers_count":32,"open_issues_count":1,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-19T12:42:20.819Z","etag":null,"topics":["ddp","ddp-publish","ddp-subscription","meteor","meteor-package"],"latest_commit_sha":null,"homepage":"https://atmospherejs.com/peerlibrary/subscription-data","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peerlibrary.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-20T18:02:38.000Z","updated_at":"2022-09-14T12:44:36.000Z","dependencies_parsed_at":"2023-02-23T14:45:12.388Z","dependency_job_id":null,"html_url":"https://github.com/peerlibrary/meteor-subscription-data","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peerlibrary%2Fmeteor-subscription-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peerlibrary%2Fmeteor-subscription-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peerlibrary%2Fmeteor-subscription-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peerlibrary%2Fmeteor-subscription-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peerlibrary","download_url":"https://codeload.github.com/peerlibrary/meteor-subscription-data/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252596422,"owners_count":21773845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ddp","ddp-publish","ddp-subscription","meteor","meteor-package"],"created_at":"2024-11-09T06:05:41.429Z","updated_at":"2025-05-06T00:10:41.015Z","avatar_url":"https://github.com/peerlibrary.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"subscription data context\n=========================\n\nThis Meteor smart package provides a reactive and shared (between client and server side)\nsubscription data context. When you [subscribe](http://docs.meteor.com/#/full/meteor_subscribe)\nto a publish endpoint, a reactive data context is established which can be read and changed both\non the client or server side to provide alternative (reactive) way of passing arguments\nto the publish endpoint, without subscription restarting. To be useful, use\n[peerlibrary:reactive-publish](https://github.com/peerlibrary/meteor-reactive-publish) and\n[server-side autorun](https://github.com/peerlibrary/meteor-server-autorun) in your publish\nendpoint function to react to data context changes.\n\nAdding this package to your [Meteor](http://www.meteor.com/) application extends\npublish endpoint function's `this` and subscription's handle with `data` and `setData` methods.\n\nBoth client and server side.\n\nInstallation\n------------\n\n```\nmeteor add peerlibrary:subscription-data\n```\n\nAPI\n---\n\nThe subscription handle returned from [`Meteor.subscribe`](http://docs.meteor.com/#/full/meteor_subscribe)\ncontains two new methods:\n\n* `data(path)` – returns current data context object; if `path` is specified, returns value under `path` in the data\n  context; it uses [data-lookup](https://github.com/peerlibrary/meteor-data-lookup) package to resolve the path\n* `setData(path, value)` - sets the value under `path` in the data context object to `value`; if `value` is `undefined`,\n  path is unset; alternatively, you can pass the whole new data context object which will be used as the new data context\n\nSame methods are available also inside the [publish endpoint](http://docs.meteor.com/#/full/meteor_publish) function\nthrough `this`.\n\nExamples\n--------\n\nIf on the server side you have such publish endpoint:\n\n```javascript\nMeteor.publish('infinite-scroll', function () {\n  var self = this;\n\n  self.autorun(function (computation) {\n    self.setData('countAll', MyCollection.find().count());\n  });\n\n  self.autorun(function (computation) {\n    var limit = self.data('limit') || 10;\n    // Do not forget to check the data.\n    check(limit, Number);\n\n    return MyCollection.find({}, {limit: limit, sort: {timestamp: -1}});\n  });\n});\n```\n\nThen you can on the client side subscribe to it and control it without restarting the subscription:\n\n```javascript\nvar subscription = Meteor.subscribe('infinite-scroll');\n\n// Returns the count of all documents in the\n// collection, even if only a subset is published.\nsubscription.data('countAll');\n\n// Sets a new limit for published documents. Only the extra documents\n// are send to the client and subscription does not restart.\nsubscription.setData('limit', 20);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeerlibrary%2Fmeteor-subscription-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeerlibrary%2Fmeteor-subscription-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeerlibrary%2Fmeteor-subscription-data/lists"}