Comments (2)
Figured out the reason: new Injection Scope that Nest v6 provides
Nest v6 provides a way for you to scope your services to the RequestScope. Which means for every request, a new instance of the Service is created. This also allows you to have access to the Request context in the Service by using @Inject(REQUEST)
I utilized this scoped feature and create like a CurrentUserService
to use across my app. This allows me to not passing in currentUser
for every single methods that need the current logged in user.
The problem is CurrentUserService
being request scoped makes whatever services that inject CurrentUserService
request scoped as well. CurrentUserService -- injected --> BookingService
Booking Service will be request scoped as well.
A request scoped service cannot be used to run cron job. So be careful if you're using Scope.REQUEST
.
Closing
from nest-schedule.
Figured out the reason: new Injection Scope that Nest v6 provides
Nest v6 provides a way for you to scope your services to the RequestScope. Which means for every request, a new instance of the Service is created. This also allows you to have access to the Request context in the Service by using
@Inject(REQUEST)
I utilized this scoped feature and create like a
CurrentUserService
to use across my app. This allows me to not passing incurrentUser
for every single methods that need the current logged in user.The problem is
CurrentUserService
being request scoped makes whatever services that injectCurrentUserService
request scoped as well.CurrentUserService -- injected --> BookingService
Booking Service will be request scoped as well.A request scoped service cannot be used to run cron job. So be careful if you're using
Scope.REQUEST
.Closing
Thank you very much. 👍
from nest-schedule.
Related Issues (20)
- Spawn new process on job execution HOT 3
- Error: Cannot find module '@nestjs/core/injector/constants' HOT 2
- `startTime` and `endTime` are not documented? HOT 1
- Date-based Scheduling and RecurrenceRule not support
- unit testing nest-schedule HOT 1
- TimeoutJob after Server Reboot HOT 2
- Timeout-Job only exception 32bit Integer for timeout
- Processing Events
- Support for Object Literal
- Can't get interval/cron working HOT 1
- testing/debugging config
- Cancel All Jobs HOT 1
- Questions about a similar repo @nestjs/schedule
- applyDecorators is not a function HOT 2
- Eslint config is polluting my vs code
- config.waiting does not work HOT 3
- Can expression be modified during operation
- How do I upgrade from 0.4 to 0.6
- Update for Nest 7 HOT 4
- How to use Timezone ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nest-schedule.