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

Nested env not working. #460

Open
kencana16 opened this issue May 13, 2024 · 0 comments
Open

Nested env not working. #460

kencana16 opened this issue May 13, 2024 · 0 comments

Comments

@kencana16
Copy link

kencana16 commented May 13, 2024

i have class like this


@Environment("cloud")
@Injectable(as: IClassA)
class ClassA {
  final ClassB classb;

  ClassA(this.classb);
}

@Environment("cloud")
@Injectable()
class ClassB {}

@Environment("local")
@Injectable(as: IClassA)
class OtherClassA {
  OtherClassA();
}

the generated file become

gh.factory<ClassB>(
        () => ClassB(),
        registerFor: {_cloud},
);
gh.factory<IClassA>(
        () => ClassA(
          gh<ClassB>(),
        ),
        registerFor: {_cloud},
);
gh.factory<IClassA>(
        () => OtherClassA(),
        registerFor: {_local},
);

when ClassB only registered if environment contain _cloud, so ClassA factory become error because classB doesn't registered in getIt.

@kencana16 kencana16 changed the title i have ClassA depend ClassB. both is using env "cloud". than i register OtherClassA(as: ClassA) using env "local". Nested env not working. May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant