Skip to main content
Version: v1

IntervalCollection Class

Signature

export declare class IntervalCollection<TInterval extends ISerializableInterval> extends TypedEventEmitter<IIntervalCollectionEvent<TInterval>>

Extends: TypedEventEmitter<IIntervalCollectionEvent

Type Parameters

Parameter Constraint Description
TInterval ISerializableInterval

Remarks

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the IntervalCollection class.

Properties

Property Type Description
attached boolean

Methods

Method Alerts Return Type Description
[Symbol.iterator]() IntervalCollectionIterator<TInterval>
add(start, end, intervalType, props) TInterval Create a new interval and add it to the collection
addConflictResolver(conflictResolver) void
addInternal(serializedInterval, local, op) Deprecated TInterval
attachDeserializer(onDeserialize) void
attachGraph(client, label) void
change(id, start, end) TInterval | undefined
changeInterval(serializedInterval, local, op) Deprecated void
changeProperties(id, props) void
CreateBackwardIteratorWithEndPosition(endPosition) IntervalCollectionIterator<TInterval>
CreateBackwardIteratorWithStartPosition(startPosition) IntervalCollectionIterator<TInterval>
CreateForwardIteratorWithEndPosition(endPosition) IntervalCollectionIterator<TInterval>
CreateForwardIteratorWithStartPosition(startPosition) IntervalCollectionIterator<TInterval>
deleteInterval(serializedInterval, local, op) Deprecated void
findOverlappingIntervals(startPosition, endPosition) TInterval[]
gatherIterationResults(results, iteratesForward, start, end) void
getIntervalById(id) TInterval
map(fn) void
nextInterval(pos) TInterval
previousInterval(pos) TInterval
removeIntervalById(id) TInterval

Property Details

attached

Signature

get attached(): boolean;

Type: boolean

Method Details

[Symbol.iterator]

Signature

[Symbol.iterator](): IntervalCollectionIterator<TInterval>;

Returns

Return type: IntervalCollectionIterator<TInterval>

add

Create a new interval and add it to the collection

Signature

add(start: number, end: number, intervalType: IntervalType, props?: PropertySet): TInterval;

Parameters

Parameter Modifiers Type Description
start number interval start position
end number interval end position
intervalType IntervalType type of the interval. All intervals are SlideOnRemove. Intervals may not be Transient.
props optional PropertySet properties of the interval

Returns

  • the created interval

Return type: TInterval

addConflictResolver

Signature

addConflictResolver(conflictResolver: IntervalConflictResolver<TInterval>): void;

Parameters

Parameter Type Description
conflictResolver IntervalConflictResolver<TInterval>

addInternal

This API is deprecated and will be removed in a future release.
  • use ackAdd

Signature

addInternal(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): TInterval;

Parameters

Parameter Type Description
serializedInterval ISerializedInterval
local boolean
op ISequencedDocumentMessage

Returns

Return type: TInterval

attachDeserializer

Signature

attachDeserializer(onDeserialize: DeserializeCallback): void;

Parameters

Parameter Type Description
onDeserialize DeserializeCallback

attachGraph

Signature

attachGraph(client: Client, label: string): void;

Parameters

Parameter Type Description
client Client
label string

change

Signature

change(id: string, start?: number, end?: number): TInterval | undefined;

Parameters

Parameter Modifiers Type Description
id string
start optional number
end optional number

Returns

Return type: TInterval | undefined

changeInterval

This API is deprecated and will be removed in a future release.
  • use ackChange

Signature

changeInterval(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;

Parameters

Parameter Type Description
serializedInterval ISerializedInterval
local boolean
op ISequencedDocumentMessage

changeProperties

Signature

changeProperties(id: string, props: PropertySet): void;

Parameters

Parameter Type Description
id string
props PropertySet

CreateBackwardIteratorWithEndPosition

Signature

CreateBackwardIteratorWithEndPosition(endPosition: number): IntervalCollectionIterator<TInterval>;

Parameters

Parameter Type Description
endPosition number

Returns

Return type: IntervalCollectionIterator<TInterval>

CreateBackwardIteratorWithStartPosition

Signature

CreateBackwardIteratorWithStartPosition(startPosition: number): IntervalCollectionIterator<TInterval>;

Parameters

Parameter Type Description
startPosition number

Returns

Return type: IntervalCollectionIterator<TInterval>

CreateForwardIteratorWithEndPosition

Signature

CreateForwardIteratorWithEndPosition(endPosition: number): IntervalCollectionIterator<TInterval>;

Parameters

Parameter Type Description
endPosition number

Returns

Return type: IntervalCollectionIterator<TInterval>

CreateForwardIteratorWithStartPosition

Signature

CreateForwardIteratorWithStartPosition(startPosition: number): IntervalCollectionIterator<TInterval>;

Parameters

Parameter Type Description
startPosition number

Returns

Return type: IntervalCollectionIterator<TInterval>

deleteInterval

This API is deprecated and will be removed in a future release.
  • use ackDelete

Signature

deleteInterval(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;

Parameters

Parameter Type Description
serializedInterval ISerializedInterval
local boolean
op ISequencedDocumentMessage

findOverlappingIntervals

Signature

findOverlappingIntervals(startPosition: number, endPosition: number): TInterval[];

Parameters

Parameter Type Description
startPosition number
endPosition number

Returns

Return type: TInterval[]

gatherIterationResults

Signature

gatherIterationResults(results: TInterval[], iteratesForward: boolean, start?: number, end?: number): void;

Parameters

Parameter Modifiers Type Description
results TInterval[]
iteratesForward boolean
start optional number
end optional number

getIntervalById

Signature

getIntervalById(id: string): TInterval;

Parameters

Parameter Type Description
id string

Returns

Return type: TInterval

map

Signature

map(fn: (interval: TInterval) => void): void;

Parameters

Parameter Type Description
fn (interval: TInterval) => void

nextInterval

Signature

nextInterval(pos: number): TInterval;

Parameters

Parameter Type Description
pos number

Returns

Return type: TInterval

previousInterval

Signature

previousInterval(pos: number): TInterval;

Parameters

Parameter Type Description
pos number

Returns

Return type: TInterval

removeIntervalById

Signature

removeIntervalById(id: string): TInterval;

Parameters

Parameter Type Description
id string

Returns

Return type: TInterval