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

Can you just use GetIt syntax? #53

Closed
Kiwi-KiwiCorp opened this issue Feb 22, 2022 · 2 comments
Closed

Can you just use GetIt syntax? #53

Kiwi-KiwiCorp opened this issue Feb 22, 2022 · 2 comments

Comments

@Kiwi-KiwiCorp
Copy link

As your package uses GetIt, would it still work if we registered dependencies using the GetIt syntax?

For example:

final getIt = GetIt.instance;

void setup() {
  getIt.registerSingleton<AppModel>(AppModel());
}

I only ask because if I'm being honest, I think the cubes syntax is less readable than the standard GetIt syntax with the use of the type parameter. In addition, it looks like your missing a few features from the standard GetIt syntax such as Scopes and the ability to unregister a dependency.

I think cubes would be much more popular if instead of creating your own abstraction you simply let people use the GetIt syntax or even simply created a global variable called cubes like the 'getit' variable in the example above so that our code would look like this:

// global variable defined in the cubes package
final cubes = GetIt.instance;

// use in our code
void setup() {
  cubes.registerSingleton<AppModel>(AppModel());
}
@RafaelBarbosatec
Copy link
Owner

It’s a good point. I'll improve this syntax. But i thing that not necessary de possibility of the create a global variable.

Thanks so much!

@RafaelBarbosatec
Copy link
Owner

Available in 1.5.0 version.

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

2 participants