-
Notifications
You must be signed in to change notification settings - Fork 148
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
@lazySingleton creates at start when @PostConstruct(preResolve: true) #486
Comments
that makes sense, because the instance is resolved at setup phase, try disabling preResolve |
Ok. In next days, I will test this setup and send here the conclusion |
@Milad-Akarie I changed this and had other problem. Other injectables that need required parameter, receive nullable parameters. In this generate code, facilityNid is nullable: gh.factoryParamAsync<_i327.FacilityMapDetailViewModel, int, dynamic>((
facilityNid,
_,
) async =>
_i327.FacilityMapDetailViewModel(
env: gh<_i679.Env>(),
facilitiesUseCase: await getAsync<_i39.GetFacilitiesUseCase>(),
facilityNid: facilityNid,
)); This is because this package code, where P1 and P2 are nullable:
My current solution was:
Desired behavior: |
Where do you expect the param for factory to come from? Normally you would pass it as you create the instance |
Problem
I don't know if I'm misunderstanding
PostConstruct
proposal, but I think it doesn't work as expected.I have a use_case file which is
lazySingleton
. Inside this, a method (call) that needs to be initialized before using the use_case.Current behavior:
The singleton is being initialized when I run the application and not when it is called for the first time (at home).
Expected behavior:
I would like it to be initialized only when I call it at home.
Other info
If I remove the
PostConstruct
, it works.Setup
injectable version: 2.5.0
get_it version: 8.0.2
Code:
Generated code:
The text was updated successfully, but these errors were encountered: