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

Cannot find name "JobCollection" #232

Open GuofuHuang opened 7 years ago

GuofuHuang commented 7 years ago

I just install this package, and I'm using Angular2. But when I start the app, it said that "it cannot find name "JobCollection", anyone knows how to solve it?

vsivsi commented 7 years ago

If it is installed correctly, it should be globally visible. Although depending on your tooling, you may need to import it. I recommend looking at a working sample app if you are just getting started:

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

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

gh0st commented 7 years ago

@GuofuHuang this is typical of an angular2 app and like @vsivsi said you might need to import it. When is it that you see this message? Is it in your editor, when you start your app, in your browsers console? Can you give us some context?

mibto commented 7 years ago

@GuofuHuang problem is that typescript is not aware of the package because of a missing type declaration.

declare module 'meteor/vsivsi:job-collection' {
    export class JobCollection {
        constructor( databaseName: string );

        find( query: Object, options?: Object );

        startJobServer();

        allow( options: Object );

        processJobs( type: string, options: Object, worker: ( result: any, callback: any ) => void )
    }

    export class Job {
        constructor( jobCollection: JobCollection, type: string, options: Object );

        priority( priority: string ): Job;

        retry( options: Object ): Job;

        delay( delay: number ): Job;

        save();
    }
}

i never wrote one of those and i'm hoping for some help as well ;)

pedrofg commented 6 years ago

import { JobCollection, Job } from 'meteor/vsivsi:job-collection';