Pool class
Pool is a depdency injection tool designed specifically for managing stores acros your apps. It's recommended that you still use Provider/Consumer for passing around other dependencies or some other serivce locator as it can be really hectic if you try to make it with Pool.
Pool from the name is a collection of Stores
. Where all the stores are stores in a singleton but it doesn't
create singletons of the Stores
itself. Every store is represented with a unique id called StoreToken
, this token
is used to reference a partiuclar instance it has been registered with.
Pool tries to replicate the standard way of releasing resources when they have been used like the Widget
but without any context.
The life cycle of a store is:
- register
- initialized
- disposed
Once your store has been disposed its StoreToken
can no loger access or re-initialize the store. But there are certain exceptions,
sometimes a store's life cycle is short and it get's created and disposed again, but we can't create and reference
at compile time in such conditions, to overcome that a store can be initialized as recreateable, which can be
uninitialized which means release the resources but still being able to use the same token to create another instances.
In such a case the life cycle of a store becomes:
- register
- initialize
- uninitialize
To use it first you need to register an instance to get a token, this can be done by calling Pool.instance.register()
Constructors
- Pool()
-
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
create(
StoreToken token, {bool recreate = false}) → void - Initializes the Store
-
disposeStore<
T> (StoreToken token, StoreDisposer< T> ? dispose) → void - Registers a token and initializes the store Disposes a store
-
getTokenStatus(
StoreToken token) → StoreTokenStatus -
Get current status of a
StoreToken
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
obtain<
T> (StoreToken token) → T - Returns the store instance from the token
-
register<
T> (T createInstance()) → StoreToken< T> - Returns a store token without instantiating
-
toString(
) → String -
A string representation of this object.
inherited
-
uninitialize<
T> (StoreToken token, StoreDisposer< T> ? dispose) → void - Releases the resources of a recreateable store
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited