The most basic CRDT: an integer value that can be changed only by incrementing and decrementing. Since addition of integers is commutative, the value trivially converges.

Hierarchy

  • Counter

Constructors

Properties

Methods

Constructors

Properties

value: number

Methods

  • Decreases the value of the counter by delta. If delta is not given, decreases the value of the counter by 1.

    Will throw an error if used outside of a change callback.

    Parameters

    • _delta: number

    Returns number

  • Increases the value of the counter by delta. If delta is not given, increases the value of the counter by 1.

    Will throw an error if used outside of a change callback.

    Parameters

    • _delta: number

    Returns number

  • Returns the counter value, so that a JSON serialization of an Automerge document represents the counter simply as an integer.

    Returns number

  • Returns the counter value as a decimal string. If x is a counter object, this method is called e.g. when you do ['value: ', x].join('') or when you use string interpolation: value: ${x}.

    Returns string

Generated using TypeDoc