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

SharedCollection is a simple ListCollectionView which is shared across the AFCS 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 the properties of any object in the collection (without calling setItemAt to update the collection) will not be 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.

At the moment (due to issues with the service which we're investigating), class types are not preserved once sent and received from the service. However, by specifying the itemClass property of the SharedCollection, the collection will automatically create instances of the appropriate class and transfer 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 apps 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



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 - typically this assigns the sharedID of the collectionNode used by the component.
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
   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.

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