Sync Android SDK  0.8.7
com.twilio.sync.MapObserver Class Referenceabstract

Observer for all operations on a Map. More...

Public Member Functions

 MapObserver ()
 Keep default constructor, you don't need to override it. More...
 
void onOpened (Map map)
 This callback is invoked when Map object has been initialised and opened locally. More...
 
void onItemAdded (EventContext context, Map.Item itemSnapshot)
 This callback is invoked when Map item has been added. More...
 
void onItemUpdated (EventContext context, Map.Item itemSnapshot, JSONObject prevItemSnapshot)
 This callback is invoked when Map item has been updated. More...
 
void onItemRemoved (EventContext context, String itemKey, JSONObject prevDataSnapshot)
 This callback is invoked when Map item has been removed. More...
 
void onCollectionRemoved (EventContext context)
 This callback is invoked when the entire Map has been removed. More...
 
void onErrorOccurred (ErrorInfo error)
 This callback is invoked when a Map operation has encountered a error in local request. More...
 

Detailed Description

Observer for all operations on a Map.

You should create your own subclass of MapObserver and override functions you are interested in.

Observer will receive callbacks for all operations on a Map. To distinguish parallel streams of local operations your application could use local flow identifier.

Callbacks in the observer will be called from a background thread. You will need to repost your work to UI thread if you do any UI-related operations in the callback.

Constructor & Destructor Documentation

com.twilio.sync.MapObserver.MapObserver ( )

Keep default constructor, you don't need to override it.

If you do override make sure to call the inherited constructor.

Member Function Documentation

void com.twilio.sync.MapObserver.onCollectionRemoved ( EventContext  context)

This callback is invoked when the entire Map has been removed.

Parameters
contextContext indicating if change was local or remote.
void com.twilio.sync.MapObserver.onErrorOccurred ( ErrorInfo  error)

This callback is invoked when a Map operation has encountered a error in local request.

Parameters
errorError description.
void com.twilio.sync.MapObserver.onItemAdded ( EventContext  context,
Map.Item  itemSnapshot 
)

This callback is invoked when Map item has been added.

Parameters
contextContext indicating if change was local or remote.
itemSnapshotSnapshot of the item that was added.
void com.twilio.sync.MapObserver.onItemRemoved ( EventContext  context,
String  itemKey,
JSONObject  prevDataSnapshot 
)

This callback is invoked when Map item has been removed.

Parameters
contextContext indicating if change was local or remote.
itemKeyKey of the item that has been removed.
prevDataSnapshotSnapshot of the item immediately prior deletion.
void com.twilio.sync.MapObserver.onItemUpdated ( EventContext  context,
Map.Item  itemSnapshot,
JSONObject  prevItemSnapshot 
)

This callback is invoked when Map item has been updated.

Parameters
contextContext indicating if change was local or remote.
itemSnapshotSnapshot of the item after the change.
prevItemSnapshotSnapshot of the item before the change.
void com.twilio.sync.MapObserver.onOpened ( Map  map)

This callback is invoked when Map object has been initialised and opened locally.

Parameters
mapMap object that has been opened. This parameter you should take and use as your initialised instance of a map.