Skip to content

Commit

Permalink
Merge pull request #378 from kuhnroyal/fix/typos
Browse files Browse the repository at this point in the history
Fix typos
  • Loading branch information
escamoteur authored Oct 21, 2024
2 parents d6cc02f + 3602eda commit ebc9df1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
14 changes: 7 additions & 7 deletions lib/get_it.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract mixin class ShadowChangeHandlers {

/// If objects that are registered inside GetIt implements [Disposable] the
/// [onDispose] method will be called whenever that Object is unregistered,
/// resetted or its enclosing Scope is popped
/// reset or its enclosing Scope is popped
abstract mixin class Disposable {
FutureOr onDispose();
}
Expand Down Expand Up @@ -153,7 +153,7 @@ abstract class GetIt {
bool allowReassignment = false;

/// By default it's throws error when [allowReassignment]= false. and trying to register same type
/// If you really need, you can disable the Asserts / Errror by setting[skipDoubleRegistration]= true
/// If you really need, you can disable the Asserts / Error by setting[skipDoubleRegistration]= true
@visibleForTesting
bool skipDoubleRegistration = false;

Expand Down Expand Up @@ -343,24 +343,24 @@ abstract class GetIt {
///
/// [registerSingletonIfAbsent] and [releaseInstance] are used to manage the lifecycle of
/// a Singleton. This is useful if you register an object when you push a Page and this page can get
/// pused recursively. In that case you don't want to dispose the object when first of these pages is popped
/// pushed recursively. In that case you don't want to dispose the object when first of these pages is popped
///
/// Only registers a type new as Singleton if it is not already registered. Otherwise it returns
/// the existing instance and increments an internal reference counter to ensure that matching
/// [unregister] or [releaseInstance] calls will decrement the reference counter an won't unregister
/// and dispose the registration as long as the reference counter is > 0.
/// [T] type/interface that is used for the registration and the access via [get]
/// [factoryFunc] that is callled to create the instance if it is not already registered
/// [factoryFunc] that is called to create the instance if it is not already registered
/// [instanceName] optional key to register more than one instance of one type
/// [dispose] disposing function that is autmatically called before the object is removed from get_it
/// [dispose] disposing function that is automatically called before the object is removed from get_it
T registerSingletonIfAbsent<T extends Object>(
T Function() factoryFunc, {
String? instanceName,
DisposingFunc<T>? dispose,
});

/// checks if a regiserter Singleton has an reference counter > 0
/// checks if a registered Singleton has an reference counter > 0
/// if so it decrements the reference counter and if it reaches 0 it
/// unregisters the Singleton
/// if called on an object that's reference counter was never incremented
Expand Down Expand Up @@ -576,7 +576,7 @@ abstract class GetIt {
/// [instanceName] if you need to dispose any resources you can do it using
/// [disposingFunction] function that provides an instance of your class to be disposed.
/// This function overrides the disposing you might have provided when registering.
/// If you have enabled referece counting when registering, [unregister] will only unregister and dispose the object
/// If you have enabled reference counting when registering, [unregister] will only unregister and dispose the object
/// if referenceCount is 0
/// [ignoreReferenceCount] if `true` it will ignore the reference count and unregister the object
/// only use this if you know what you are doing
Expand Down
36 changes: 18 additions & 18 deletions lib/get_it_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ enum _ServiceFactoryType {
alwaysNew, // factory which means on every call of [get] a new instance is created
constant, // normal singleton
lazy, // lazy
cachedFactory, // cached factoryj
cachedFactory, // cached factory
}

/// If I use `Singleton` without specifier in the comments I mean normal and lazy
Expand Down Expand Up @@ -114,7 +114,7 @@ class _ServiceFactory<T extends Object, P1, P2> {

final bool shouldSignalReady;

int _refenceCount = 0;
int _referenceCount = 0;

_ServiceFactory(
this._getItInstance,
Expand Down Expand Up @@ -251,7 +251,7 @@ class _ServiceFactory<T extends Object, P1, P2> {
}

/// returns an async instance depending on the type of the registration if [async==true] or
/// if [dependsOn.isnoEmpty].
/// if [dependsOn.isNotEmpty].
Future<R> getObjectAsync<R>(dynamic param1, dynamic param2) async {
assert(
!(factoryType != _ServiceFactoryType.alwaysNew &&
Expand Down Expand Up @@ -512,7 +512,7 @@ class _GetItImplementation implements GetIt {
bool allowReassignment = false;

/// By default it's throws error when [allowReassignment]= false. and trying to register same type
/// If you really need, you can disable the Asserts / Errror by setting[skipDoubleRegistration]= true
/// If you really need, you can disable the Asserts / Error by setting[skipDoubleRegistration]= true
@visibleForTesting
@override
bool skipDoubleRegistration = false;
Expand Down Expand Up @@ -943,9 +943,9 @@ class _GetItImplementation implements GetIt {
/// [unregister] or [releaseInstance] calls will decrement the reference counter an won't unregister
/// and dispose the registration as long as the reference counter is > 0.
/// [T] type/interface that is used for the registration and the access via [get]
/// [factoryFunc] that is callled to create the instance if it is not already registered
/// [factoryFunc] that is called to create the instance if it is not already registered
/// [instanceName] optional key to register more than one instance of one type
/// [dispose] disposing function that is autmatically called before the object is removed from get_it
/// [dispose] disposing function that is automatically called before the object is removed from get_it
@override
T registerSingletonIfAbsent<T extends Object>(
T Function() factoryFunc, {
Expand All @@ -960,7 +960,7 @@ class _GetItImplementation implements GetIt {
!existingFactory.isAsync,
StateError(
'registerSingletonIfAbsent can only be called for a type that is already registered as Singleton and not for factories or async/lazy Singletons'));
existingFactory._refenceCount++;
existingFactory._referenceCount++;
return existingFactory.instance!;
}

Expand All @@ -976,20 +976,20 @@ class _GetItImplementation implements GetIt {
return instance;
}

/// checks if a regiserter Singleton has an reference counter > 0
/// checks if a registered Singleton has an reference counter > 0
/// if so it decrements the reference counter and if it reaches 0 it
/// unregisters the Singleton
/// if called on an object that's reference counter was never incremented
/// it will immediately unregister and dispose the object
@override
void releaseInstance(Object instance) {
final registerdFactory = _findFactoryByInstance(instance);
if (registerdFactory._refenceCount < 1) {
assert(registerdFactory._refenceCount == 0,
final registeredFactory = _findFactoryByInstance(instance);
if (registeredFactory._referenceCount < 1) {
assert(registeredFactory._referenceCount == 0,
'GetIt: releaseInstance was called on an object that was already released');
unregister(instance: instance);
} else {
registerdFactory._refenceCount--;
registeredFactory._referenceCount--;
}
}

Expand Down Expand Up @@ -1110,8 +1110,8 @@ class _GetItImplementation implements GetIt {
/// Unregister an instance of an object or a factory/singleton by Type [T] or by name [instanceName]
/// if you need to dispose any resources you can pass in a [disposingFunction] function
/// that provides an instance of your class to be disposed
/// If you have provided an disposing functin when you registered the object that one will be called automatically
/// If you have enabled referece counting when registering, [unregister] will only unregister and dispose the object
/// If you have provided an disposing function when you registered the object that one will be called automatically
/// If you have enabled reference counting when registering, [unregister] will only unregister and dispose the object
/// if referenceCount is 0
///
@override
Expand All @@ -1132,8 +1132,8 @@ class _GetItImplementation implements GetIt {
),
);

if (factoryToRemove._refenceCount > 0) {
factoryToRemove._refenceCount--;
if (factoryToRemove._referenceCount > 0) {
factoryToRemove._referenceCount--;
return;
}
final typeRegistration = factoryToRemove.registeredIn;
Expand Down Expand Up @@ -1361,7 +1361,7 @@ class _GetItImplementation implements GetIt {
} catch (e) {
final failedScope = _scopes.last;

/// prevend any new registrations in this scope
/// prevent any new registrations in this scope
failedScope.isFinal = true;
failedScope.reset(dispose: true);
_scopes.removeLast();
Expand Down Expand Up @@ -1416,7 +1416,7 @@ class _GetItImplementation implements GetIt {
} catch (e) {
final failedScope = _scopes.last;

/// prevend any new registrations in this scope
/// prevent any new registrations in this scope
failedScope.isFinal = true;
await failedScope.reset(dispose: true);
_scopes.removeLast();
Expand Down

0 comments on commit ebc9df1

Please sign in to comment.