Skip to main content

MergableObjectOperations <T>

Operations that a MergableObject must implement

Index

Methods

clone

  • clone(): T
  • Deep clone the object.


    Returns T

isEqual

  • isEqual(o: T): boolean
  • Returns true if objects are considered to be equal. Otherwise false


    Parameters

    • o: T

      Object to compare with.

    Returns boolean

onAdded

  • Called when the object is first added to to

    <T>
    by calling
    <T>
    .addOrUpdate and if the object does not already exist in MergableSet. In that case the local object will get MergableObjectState.Added. Also called if a remote object, for which there is no corresponding local or remote object in MergableSet, is detected during calls to
    <T>
    .saveAndMerge or
    <T>
    .loadAndMerge. In that case the local object get the state MergableObjectState.Unchanged.


    Parameters

    • o: MergableObjectEventArgs<T>

      Gives both local and (optional) remote representation of object. Also gives (rare but possible) conflict reason if it exists. A conflict may occur if a local object with same MergableObject.id has been added by calling

      <T>
      .addOrUpdate when no remote counterpart existed. Once
      <T>
      .saveAndMerge or
      <T>
      .loadAndMerge is called a remote counter part (same id) is detected and their content differs. This should only happen if non unique id's are assigned to objects.

    Returns void

onDelete

  • Called when

    • Layer
      <T>
      .delete is called.
    • Layer
      <T>
      .save or Layer
      <T>
      .load is called and item exists in client (and is unchanged) but no longer in backend. That means that somebody has removed it and store that in the backend. Hence it must be removed

    Parameters

    • o: MergableObjectEventArgs<T>

      Gives both local and (optional) remote representation of object. Also gives (rare but possible) conflict reason if it exists. A conflict may occur if a local object with same MergableObject.id has been added by calling

      <T>
      .addOrUpdate when no remote counterpart existed. Once
      <T>
      .saveAndMerge or
      <T>
      .loadAndMerge is called a remote counter part (same id) is detected and their content differs. This should only happen if non unique id's are assigned to objects.

    Returns void

    true if there is no conflict or conflict could be resolved.

onUpdate

  • This event is called when local object already exists in

    <T>
    and does not have state MergableObjectState.Added and one of the following holds true

    1. If state is MergableObjectState.Unchanged and a call to
      <T>
      .loadAndMerge or
      <T>
      .saveAndMerge results in a detection that the remote object has changed and it differs from the local object
    2. Calling
      <T>
      .addOrUpdate

    Parameters

    • o: MergableObjectEventArgs<T>

      Gives both local and (optional) remote representation of object. Also gives (rare but possible) conflict reason if it exists. A conflict may occur if a local object with same MergableObject.id has been added by calling

      <T>
      .addOrUpdate when no remote counterpart existed. Once
      <T>
      .saveAndMerge or
      <T>
      .loadAndMerge is called a remote counter part (same id) is detected and their content differs. This should only happen if non unique id's are assigned to objects.

    Returns void