vsivsi / meteor-job-collection

A persistent and reactive job queue for Meteor, supporting distributed workers that can run anywhere.
https://atmospherejs.com/vsivsi/job-collection
Other
388 stars 68 forks source link

How to reference existing job collection from the client side that was created server side? #238

Open gh0st opened 7 years ago

gh0st commented 7 years ago

What's the ideal way of referencing an existing job collection on the client side? Following the example I create my job collection like so:

if (Meteor.isServer) {
    var myJobs = JobCollection('myJobQueue');
}

This also works on my client side only once when my component is first initialized but if I navigate back to my component I get a Error: There is already a collection named "myJobQueue.jobs". But if the example client code we have again

if (Meteor.isClient) {
    var myJobs = JobCollection('myJobQueue');
}
vsivsi commented 7 years ago

I suggest you look at one of the complete sample apps, each of which does exactly what you are asking:

https://github.com/vsivsi/meteor-job-collection-playground https://github.com/vsivsi/meteor-file-job-sample-app