Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set time from config service to decorator #24

Open
grigori-gru opened this issue May 31, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@grigori-gru
Copy link

commented May 31, 2019

Is it possible to set time to decorator from configService which I use as dependency in my job module, for example this way:

export class JobService extends NestSchedule {
    private readonly logger = new Logger(JobService.name);

    constructor(
        private readonly configSerice: ConfigService,
    ) {
        super();
    }

    @Cron('10 0 * * *')
    async saveVoteResult2Db() {
        this.logger.log('Starting daily cronjob!!!');
    }

    @Interval(this.configSerice.syncInterval)
    async saveToRedis() {
        this.logger.debug('Data is synced with redis');
    }
@issue-label-bot

This comment has been minimized.

Copy link

commented May 31, 2019

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

@miaowing

This comment has been minimized.

Copy link
Owner

commented Jun 4, 2019

The this context is different between decorator and function, not use this in decorator

@miaowing miaowing added the question label Jun 4, 2019

@grigori-gru

This comment has been minimized.

Copy link
Author

commented Jun 5, 2019

Thanks, but how should I use it in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.