Sync Android SDK  2.0.2
com.twilio.sync.SyncMapObserver Class Referenceabstract

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

Public Member Functions

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

Detailed Description

Observer for all operations on a SyncMap.

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

Observer will receive callbacks for all operations on a SyncMap. 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.SyncMapObserver.SyncMapObserver ( )

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.SyncMapObserver.onCollectionRemoved ( EventContext  context)

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

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

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

Parameters
errorError description.
void com.twilio.sync.SyncMapObserver.onItemAdded ( EventContext  context,
SyncMap.Item  item 
)

This callback is invoked when SyncMap item has been added.

Parameters
contextContext indicating if change was local or remote.
itemThe item that was added.
void com.twilio.sync.SyncMapObserver.onItemRemoved ( EventContext  context,
String  itemKey,
JSONObject  previousItemData 
)

This callback is invoked when SyncMap item has been removed.

Parameters
contextContext indicating if change was local or remote.
itemKeyKey of the item that has been removed.
previousItemDataSnapshot of the item immediately prior deletion.
void com.twilio.sync.SyncMapObserver.onItemUpdated ( EventContext  context,
SyncMap.Item  item,
JSONObject  previousItemData 
)

This callback is invoked when SyncMap item has been updated.

Parameters
contextContext indicating if change was local or remote.
itemThe item after the change.
previousItemDataSnapshot of the item before the change.
void com.twilio.sync.SyncMapObserver.onOpened ( SyncMap  syncMap)

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

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