ISequenceIntervalCollection Interface
Collection of intervals that supports addition, modification, removal, and efficient spatial querying. Changes to this collection will be incur updates on collaborating clients (i.e. they are not local-only).
To use, import via @fluidframework/sequence/legacy
.
For more information about our API support guarantees, see here.
Signature
export interface ISequenceIntervalCollection extends TypedEventEmitter<ISequenceIntervalCollectionEvents>
Extends: TypedEventEmitter<ISequenceIntervalCollectionEvents>
Properties
Property | Alerts | Modifiers | Type | Description |
---|---|---|---|---|
attached | Alpha |
readonly |
boolean |
Methods
Method | Alerts | Return Type | Description |
---|---|---|---|
[Symbol.iterator]() | Alpha |
Iterator<SequenceInterval> | |
add({ start, end, props, }) | Alpha |
SequenceInterval | Creates a new interval and add it to the collection. |
attachDeserializer(onDeserialize) | Deprecated , Alpha |
void | |
attachIndex(index) | Alpha |
void | Attaches an index to this collection. All intervals which are part of this collection will be added to the index, and the index will automatically be updated when this collection updates due to local or remote changes. |
change(id, { start, end, props }) | Alpha |
SequenceInterval | undefined | Changes the endpoints, properties, or both of an existing interval. |
CreateBackwardIteratorWithEndPosition(endPosition) | Alpha |
Iterator<SequenceInterval> | |
CreateBackwardIteratorWithStartPosition(startPosition) | Alpha |
Iterator<SequenceInterval> | |
CreateForwardIteratorWithEndPosition(endPosition) | Alpha |
Iterator<SequenceInterval> | |
CreateForwardIteratorWithStartPosition(startPosition) | Alpha |
Iterator<SequenceInterval> | |
detachIndex(index) | Alpha |
boolean | Detaches an index from this collection. All intervals which are part of this collection will be removed from the index, and updates to this collection due to local or remote changes will no longer incur updates to the index. |
findOverlappingIntervals(startPosition, endPosition) | Deprecated , Alpha |
SequenceInterval[] | |
gatherIterationResults(results, iteratesForward, start, end) | Alpha |
void | Gathers iteration results that optionally match a start/end criteria into the provided array. |
getIntervalById(id) | Alpha |
SequenceInterval | undefined | |
map(fn) | Alpha |
void | Applies a function to each interval in this collection. |
nextInterval(pos) | Deprecated , Alpha |
SequenceInterval | undefined | |
previousInterval(pos) | Deprecated , Alpha |
SequenceInterval | undefined | |
removeIntervalById(id) | Alpha |
SequenceInterval | undefined | Removes an interval from the collection. |
Property Details
attached
For more information about our API support guarantees, see here.
Signature
readonly attached: boolean;
Type: boolean
Method Details
[Symbol.iterator]
For more information about our API support guarantees, see here.
Signature
[Symbol.iterator](): Iterator<SequenceInterval>;
Returns
an iterator over all intervals in this collection.
Return type: Iterator<SequenceInterval>
add
Creates a new interval and add it to the collection.
For more information about our API support guarantees, see here.
Signature
add({ start, end, props, }: {
start: SequencePlace;
end: SequencePlace;
props?: PropertySet;
}): SequenceInterval;
Remarks
See documentation on SequenceInterval for comments on interval endpoint semantics: there are subtleties with how the current half-open behavior is represented.
Note that intervals may behave unexpectedly if the entire contents of the string are deleted. In this case, it is possible for one endpoint of the interval to become detached, while the other remains on the string.
By adjusting the side
and pos
values of the start
and end
parameters, it is possible to control whether the interval expands to include content inserted at its start or end.
See SequencePlace for more details on the model.
Example
Given the string "ABCD":
// Refers to "BC". If any content is inserted before B or after C, this
// interval will include that content
//
// Picture:
// \{start\} - A[- B - C -]D - \{end\}
// \{start\} - A - B - C - D - \{end\}
collection.add(\{ pos: 0, side: Side.After \}, \{ pos: 3, side: Side.Before \}, IntervalType.SlideOnRemove);
// Equivalent to specifying the same positions and Side.Before.
// Refers to "ABC". Content inserted after C will be included in the
// interval, but content inserted before A will not.
// \{start\} -[A - B - C -]D - \{end\}
// \{start\} - A - B - C - D - \{end\}
collection.add(0, 3, IntervalType.SlideOnRemove);
In the case of the first example, if text is deleted,
// Delete the character "B"
string.removeRange(1, 2);
The start point of the interval will slide to the position immediately before "C", and the same will be true.
\{start\} - A[- C -]D - \{end\}
In this case, text inserted immediately before "C" would be included in the interval.
string.insertText(1, "EFG");
With the string now being,
\{start\} - A[- E - F - G - C -]D - \{end\}
Parameters
Parameter | Type | Description |
---|---|---|
{ start, end, props, } | { start: SequencePlace; end: SequencePlace; props?: PropertySet; } |
Returns
- the created interval
Return type: SequenceInterval
attachDeserializer
This api is not meant or necessary for external consumption and will be removed in subsequent release
For more information about our API support guarantees, see here.
Signature
attachDeserializer(onDeserialize: DeserializeCallback): void;
Parameters
Parameter | Type | Description |
---|---|---|
onDeserialize | DeserializeCallback |
attachIndex
Attaches an index to this collection. All intervals which are part of this collection will be added to the index, and the index will automatically be updated when this collection updates due to local or remote changes.
For more information about our API support guarantees, see here.
Signature
attachIndex(index: SequenceIntervalIndex): void;
Remarks
After attaching an index to an interval collection, applications should typically store this index somewhere in their in-memory data model for future reference and querying.
Parameters
Parameter | Type | Description |
---|---|---|
index | SequenceIntervalIndex |
change
Changes the endpoints, properties, or both of an existing interval.
For more information about our API support guarantees, see here.
Signature
change(id: string, { start, end, props }: {
start?: SequencePlace;
end?: SequencePlace;
props?: PropertySet;
}): SequenceInterval | undefined;
Parameters
Parameter | Type | Description |
---|---|---|
id | string | Id of the Interval to change |
{ start, end, props } | { start?: SequencePlace; end?: SequencePlace; props?: PropertySet; } |
Returns
the interval that was changed, if it existed in the collection. Pass the desired new start position, end position, and/or properties in an object. Start and end positions must be changed simultaneously - they must either both be specified or both undefined. To only change the properties, leave both endpoints undefined. To only change the endpoints, leave the properties undefined.
Return type: SequenceInterval | undefined
CreateBackwardIteratorWithEndPosition
For more information about our API support guarantees, see here.
Signature
CreateBackwardIteratorWithEndPosition(endPosition: number): Iterator<SequenceInterval>;
Parameters
Parameter | Type | Description |
---|---|---|
endPosition | number |
Returns
a backward iterator over all intervals in this collection with end point equal to endPosition
.
Return type: Iterator<SequenceInterval>
CreateBackwardIteratorWithStartPosition
For more information about our API support guarantees, see here.
Signature
CreateBackwardIteratorWithStartPosition(startPosition: number): Iterator<SequenceInterval>;