MergableSet <P>
Index
Constructors
Accessors
Methods
Constructors
constructor
Type parameters
- P: MergableObject<P>
Returns MergableSet<P>
Accessors
publicchangeCount
Gets number of objects that are not marked as MergableObjectState.Unchanged.
Returns number
Number of changed objects.
publicconflictCount
Get number of conflicts in the set.
Returns number
Number of conflicts.
publicconflicts
Gets all conflicts.
Returns Readonly<MergableObjectWithState<P>>[]
All conflicts.
publichasChanges
Checks if there are any changed objects in the set.
Returns boolean
trueif there areobject not marked as MergableObjectState.Unchanged.
publicobjects
Gets all local objects and their remote counterparts. Includes both state and conflict reasons (if any)
Returns IterableIterator<Readonly<MergableObjectWithState<P>>, any, any>
All objects.
Methods
publicacceptChanges
Accepts changes in the set. Is only successful if no conflicts exist.
Returns boolean
trueif no conflicts existed so changes can be accepted. Otherwise,false.
publicadd
Adds an object. If object already exists, it will not be added. An object exists for items where MergableObject.id already exists.
Parameters
o: P
Object to add
Returns boolean
trueif object was added, otherwisefalse.
publicclear
Clear set
Returns void
publicdelete
Deletes a object
Parameters
local: string | Pick<P, id>
Id of object to delete
Returns boolean
trueif object was deleted. Otherwisefalse
publicget
Get object with specified id.
Parameters
id: string
Id of object to get.
Returns undefined | MergableObjectWithState<P>
publichas
Check if object with specified id exists.
Parameters
id: string
Id of matching object.
Returns boolean
trueif object exists. Otherwisefalse.
publicmergeRemotes
Merges remote objects.
Parameters
remoteObjects: P[]
Remote objects to merge.
Returns number
Number of conflicts that occured during the merge. May not be same as conflictCount (which gives all conflicts from previous merges as well.).
publicupdate
Updates an object that already exists.
Parameters
id: string
Id of object to update
updateAction: (existingItem: P) => void
function called with MergableObject instance of specified id. Caller should make any required modfifications to the object in this function.
Returns boolean
trueif object did exist, otherwisefalse.
Represents a collection of object that has a local and a remote representation. Changes are always made to the local representation of the object. However it is possible to merge remote representations of the objects. When a merge occurs new local objects may be added, updated and deleted In some cases conflicts may arise. Such as when a local object has been modified but the remote object has been deleted.