ModelBuilder<T extends Model> typedef

ModelBuilder<T extends Model> = T Function()

Utility class for storing models of your app.

Models must be of type Model. The init method of Model is called automatically when a model is added to this store. Similarly dispose method of Model is called when a model is removed from the store. You cannot add two instances of same model in the store. It will not update the underlying model even if you add twice. You can replace an instance of a model with another one using the Store.replace method.

Note that it is not necessary to use this class. If you aren't making your models from inheriting Model then use your favourite way of dependency injection.

Implementation

// The class ModelStore is lazy and does not really add any model
// until that particular model is requested. It helps in cases
// where user wants to initialize models in bulk and use them
// later or may not even use them. In this way it potentially saves resources.
typedef ModelBuilder<T extends Model> = T Function();