-
- All Implemented Interfaces:
-
com.onesignal.common.events.IEventNotifier,com.onesignal.common.modeling.IModelStoreChangeHandler,com.onesignal.common.modeling.ISingletonModelStore
public class SingletonModelStore<TModel extends Model> implements ISingletonModelStore<TModel>, IModelStoreChangeHandler<TModel>
A singleton model store implementation that wraps a backing ModelStore to manage the single Model instance.
-
-
Field Summary
Fields Modifier and Type Field Description private final TModelmodelprivate final BooleanhasSubscribersprivate final ModelStore<TModel>store
-
Constructor Summary
Constructors Constructor Description SingletonModelStore(ModelStore<TModel> store)
-
Method Summary
Modifier and Type Method Description TModelgetModel()BooleangetHasSubscribers()final ModelStore<TModel>getStore()Unitreplace(TModel model, String tag)Replace the existing model with the new model provided. Unitsubscribe(ISingletonModelStoreChangeHandler<TModel> handler)Subscribe to listen for events. Unitunsubscribe(ISingletonModelStoreChangeHandler<TModel> handler)Unsubscribe to no longer listen for events. UnitonModelAdded(TModel model, String tag)Called when a model has been added to the model store. UnitonModelUpdated(ModelChangedArgs args, String tag)Called when a model has been updated. UnitonModelRemoved(TModel model, String tag)Called when a model has been removed from the model store. -
-
Constructor Detail
-
SingletonModelStore
SingletonModelStore(ModelStore<TModel> store)
-
-
Method Detail
-
getHasSubscribers
Boolean getHasSubscribers()
-
getStore
final ModelStore<TModel> getStore()
-
replace
Unit replace(TModel model, String tag)
Replace the existing model with the new model provided.
- Parameters:
model- A model that contains all the data for the new effective model.tag- The tag which identifies how/why the model is being replaced.
-
subscribe
Unit subscribe(ISingletonModelStoreChangeHandler<TModel> handler)
Subscribe to listen for events.
- Parameters:
handler- The handler that will be called when the event(s) occur.
-
unsubscribe
Unit unsubscribe(ISingletonModelStoreChangeHandler<TModel> handler)
Unsubscribe to no longer listen for events.
- Parameters:
handler- The handler that was previous registered via subscribe.
-
onModelAdded
Unit onModelAdded(TModel model, String tag)
Called when a model has been added to the model store.
- Parameters:
model- The model that has been added.tag- The tag which identifies how/why the model was added.
-
onModelUpdated
Unit onModelUpdated(ModelChangedArgs args, String tag)
Called when a model has been updated. This callback wraps IModelChangedHandler.onChanged so users of the model store does not need to manage subscriptions to each individual Model within the store.
- Parameters:
args- The model changed arguments.tag- The tag which identifies how/why the model was updated.
-
onModelRemoved
Unit onModelRemoved(TModel model, String tag)
Called when a model has been removed from the model store.
- Parameters:
model- The model that has been removed.tag- The tag which identifies how/why the model was removed.
-
-
-
-