RafaelBarbosatec / cube

Simple State Manager (Focusing on simplicity and rebuilding only the necessary)
MIT License
35 stars 2 forks source link

Can you just use GetIt syntax? #53

Closed Kiwi-KiwiCorp closed 2 years ago

Kiwi-KiwiCorp commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Available in 1.5.0 version.