ModelBuilder<T extends SignalModel> typedef

ModelBuilder<T extends SignalModel> = T Function()

Utility class for storing models of your app.

Models must be of type SignalModel. The init method of SignalModel is called automatically when a model is added to this store. Similarly dispose method of SignalModel 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 ModelStore.replace method.

Note that it is not necessary to use this class. If you aren't making your models from SignalModel then don't provide a model to SignalWidget and 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 SignalModel> = T Function();