injectable
injectable copied to clipboard
Scope Support
Hi!
Im looking at using injectable, however, one feature that that i need to use that I have not seen mentioned in the documentation is scopes. Is this currently supported by injectable?
Hey! @AndyDavidJoyce, I didn't get the chance to play with scopes yet, could you show me a brief example on how you're using them manually?
Sample Test here
A brief explanation is here
Perhaps a brief API could look like:
@injectable(scope: 'account_scope')
class ApiClient {
static Future<ApiClient> create(Deps ...) async {
and when getIt.pushScope('account_scope')
is called, these registrations could happen.
Something along the lines of Hilt - the scoped component based DI framework for Android.
Hi! Any news about the issue? Actually, the di config code won't become more difficult:
_i1.GetIt $initGetIt(_i1.GetIt get,
{String? environment, _i2.EnvironmentFilter? environmentFilter}) {
final gh = _i2.GetItHelper(get, environment, environmentFilter);
get.onScopeChanged = (pushed) {
if(pushed) {
switch(get.currentScopeName) {
case "scope1":
// register all "scope1" dependencies
// ...
break;
case "scope2":
// register all "scope2" dependencies
// ...
break;
}
}
};
// register all default dependencies
// ...
return get;
}
I just knew about the onScopeChange callback, that makes things easier.. I'll try to implement this feature as soon as possible.
Hi. Any news about this? Would be really great to have this feature.
I'm just waiting for this feature to integrate injectable in my company's mobile app. @Milad-Akarie, I'm happy to wait as long you need!!!
+1
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions