# Class MergableObjectWithState<P>

Describes the relation between a local object and its remote counterpart. Also gives the state for the local object and (if exists) a conflict reason between the local and the remote object. A conflict typically arises when the local object has been modified and so has the remote object. Example: local object was modified but remote object was deleted. This conflict cannot be resolved automatically.

#### Type Parameters

- P

##### Index

### Constructors

constructor

### Properties

local
onStateChange
remote?

### Accessors

conflictReason
hasConflict
state

## Constructors

### constructor

- new MergableObjectWithState<P>(
  local: P,
  _state: MergableObjectState,
  _conflictReason: MergableObjectConflict,
  remote?: P,
  ): MergableObjectWithState<P>

  #### Type Parameters

  - P

  #### Parameters

  - local: P

    local object.

  - _state: MergableObjectState
  - _conflictReason: MergableObjectConflict
  - `Optional` remote: P

    Remote object (if there is one)

  #### Returns MergableObjectWithState<P>

## Properties

### local

local: P

local object.

### onStateChange

onStateChange: (p: MergableObjectWithState<P>) => void

### `Optional` remote

remote?: P

Remote object (if there is one)

## Accessors

### conflictReason

- get conflictReason(): MergableObjectConflict

  If defined then there is a conflict between the local and the remote object.

  #### Returns MergableObjectConflict

- set conflictReason(v: MergableObjectConflict): void

  Sets conflict reason (if any).

  #### Parameters

  - v: MergableObjectConflict

  #### Returns void

### hasConflict

- get hasConflict(): boolean

  `true` if a conflict exists. Otherwise `false`

  #### Returns boolean

### state

- get state(): MergableObjectState

  get current state of the local object.

  #### Returns MergableObjectState

- set state(v: MergableObjectState): void

  set current state of the local object.

  #### Parameters

  - v: MergableObjectState

  #### Returns void