Packagecom.adobe.rtc.sharedModel
Classpublic class SharedCollection
InheritanceSharedCollection Inheritance mx.collections.ListCollectionView
ImplementsISessionSubscriber

SharedCollection is a simple ListCollectionView which is shared across the LCCS services. Useful for sharing the contents of a List or Datagrid (or any other component with a dataProvider), it supports the general addItem, setItemAt, removeItemAt, and removeAll methods for updating the collection. Any changes through these APIs are shared with other users subscribed to the collection. Note, however, that changing a collection's object properties without calling setItemAt to update them results in those properties not being shared.

The collection does not share sort order: Any sorting desired should be performed on each respective client. As such, addItemAt isn't supported, although addItem is. The collection makes update decisions on items based on a unique ID. Items added to the collection should either implement the IUID interface or provide a field which is guaranteed to be unique for this collection. The SharedCollection exposes an idField property to specify which field to use as unique ID; in the case the items do not implement IUID.

Use MessageItem.registerBodyClass to preserve class types when sending and receiving from the service. Doing so automatically creates instances of the appropriate class and transfers any properties from the received item to the typed objects.

The SharedCollection exposes the ability to set NodeConfiguration options for the node upon which the items are sent. In this way the collection can have its access and publish rights assigned as well as the other settings allowed by NodeConfiguration. Note that this component supports "piggybacking" on existing CollectionNodes through its collectionNode property and its subscribe method. Developers can avoid CollectionNode proliferation in their applications by pre-supplying a CollectionNode to the collectionNode property and a nodeName (in the subscribe method) for the SharedCollection to use. If none is supplied, the SharedCollection will create its own collectionNode named for the uniqueID supplied in subscribe()for sending and receiving messages.

See also

com.adobe.rtc.messaging.NodeConfiguration
com.adobe.rtc.sharedModel.CollectionNode
mx.core.IUID


Public Properties
 PropertyDefined by
  collectionNode : CollectionNode
Specifies an existing collectionNode to use in case a developer wishes to supply their own, and avoid having the sharedCollection create a new one.
SharedCollection
  connectSession : IConnectSession
The IConnectSession with which this component is associated.
SharedCollection
  idField : String
If each item doesn't implement IUID, specifies a field within the item to use as a unique ID.
SharedCollection
  isSynchronized : Boolean
[read-only] Returns whether or not the sharedCollection has retrieved any information previously stored on the service, and is currently connected to the service.
SharedCollection
  itemClass : Class
Specifies the class to use in deserializing any items which arrive from the service.
SharedCollection
  nodeName : String
Sets the Node name for the node being create
SharedCollection
  sharedID : String
Defines the logical location of the component on the service.
SharedCollection
Public Methods
 MethodDefined by
  
SharedCollection(p_list:IList = null)
The SharedCollection constructor
SharedCollection
  
addItem(p_item:Object):void
Adds the specified item to the end of the list.
SharedCollection
  
close():void
Disposes all listeners to the network and framework classes.
SharedCollection
  
removeAll():void
Removes all items in the collection.
SharedCollection
  
removeItemAt(p_index:int):Object
Removes the item at the specified index.
SharedCollection
  
setItemAt(p_item:Object, p_index:int):Object
Replaces the item at the specified index.
SharedCollection
  
Sets the node configuration.
SharedCollection
  
subscribe():void
Tells the component to begin synchronizing with the service.
SharedCollection
Events
 EventSummaryDefined by
   Dispatched when the ICollectionView has been updated in some way.SharedCollection
   The type of event emitted when the CollectionNode is about to reconnect to the server.SharedCollection
   Dispatched when the SharedCollection goes in and out of sync with the service.SharedCollection
Property detail
collectionNodeproperty
public var collectionNode:CollectionNode

Specifies an existing collectionNode to use in case a developer wishes to supply their own, and avoid having the sharedCollection create a new one.

connectSessionproperty 
connectSession:IConnectSession  [read-write]

The IConnectSession with which this component is associated. Note that this may only be set once before subscribe is called; re-sessioning of components is not supported. Defaults to the first IConnectSession created in the application.

Implementation
    public function get connectSession():IConnectSession
    public function set connectSession(value:IConnectSession):void
idFieldproperty 
public var idField:String

If each item doesn't implement IUID, specifies a field within the item to use as a unique ID.

isSynchronizedproperty 
isSynchronized:Boolean  [read-only]

Returns whether or not the sharedCollection has retrieved any information previously stored on the service, and is currently connected to the service.

This property can be used as the source for data binding.

Implementation
    public function get isSynchronized():Boolean
itemClassproperty 
public var itemClass:Class

Specifies the class to use in deserializing any items which arrive from the service.

nodeNameproperty 
nodeName:String  [read-write]

Sets the Node name for the node being create

Implementation
    public function get nodeName():String
    public function set nodeName(value:String):void
sharedIDproperty 
sharedID:String  [read-write]

Defines the logical location of the component on the service. Typically this assigns the sharedID of the collectionNode used by the component. sharedIDs should be unique within a room if they're expressing 2 unique locations. Note that this can only be assigned once before subscribe() is called. For components with an id property, sharedID defaults to that value.

Implementation
    public function get sharedID():String
    public function set sharedID(value:String):void
Constructor detail
SharedCollection()constructor
public function SharedCollection(p_list:IList = null)

The SharedCollection constructor

Parameters
p_list:IList (default = null) — The IList this SharedCollection is meant to wrap.
Method detail
addItem()method
public override function addItem(p_item:Object):void

Adds the specified item to the end of the list.

Parameters
p_item:Object — The item to add.
close()method 
public function close():void

Disposes all listeners to the network and framework classes. Recommended for proper garbage collection of the component.

removeAll()method 
public override function removeAll():void

Removes all items in the collection.

removeItemAt()method 
public override function removeItemAt(p_index:int):Object

Removes the item at the specified index.

Parameters
p_index:int — The index of the item to remove. Note that this index is local-only; on remote collections, it's the unique ID of the item which is used to locate and remove the item.

Returns
Object — The item preivously at this location.
setItemAt()method 
public override function setItemAt(p_item:Object, p_index:int):Object

Replaces the item at the specified index.

Parameters
p_item:Object — new item to set.
 
p_index:int — index of the item to replace. Note that this index is local-only; on remote collections, it's the unique ID of the item which is used to locate and replace the item.

Returns
Object — The item previously at this location.
setNodeConfiguration()method 
public function setNodeConfiguration(p_nodeConfig:NodeConfiguration):void

Sets the node configuration.

Parameters
p_nodeConfig:NodeConfiguration — The node configuration..
subscribe()method 
public function subscribe():void

Tells the component to begin synchronizing with the service. For "headless" components such as this one, this method must be called explicitly.

Event detail
collectionChangeevent 
Event object type: mx.events.CollectionEvent

Dispatched when the ICollectionView has been updated in some way.

reconnectevent  
Event object type: mx.events.CollectionEvent

The type of event emitted when the CollectionNode is about to reconnect to the server. This typically happens automatically if the SharedCollection is still subscribed. The typical response to this event is to re-initialize any shared parts of a model from scratch since they are about to be re-received from the server.

synchronizationChangeevent  
Event object type: com.adobe.rtc.events.CollectionNodeEvent

Dispatched when the SharedCollection goes in and out of sync with the service.





 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/labs/acrobatcom/com/adobe/rtc/sharedModel/SharedCollection.html