Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate previousInterval/nextInterval APi from IntervalCollection #18060

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/soft-taxis-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"@fluidframework/sequence": minor
"@fluid-experimental/sequence-deprecated": minor
---

Deprecate API `previousInterval` and `nextInterval` from `IntervalCollection`, these functionalities are moved to the `EndpointIndex`. Users are advised to independently attach the index to the collection and utilize the API accordingly, for instance:

```typescript
const endpointIndex = createEndpointIndex(sharedString);
collection.attachIndex(endpointIndex);

const result1 = endpointIndex.previousInterval(pos);
const result2 = endpointIndex.nextInterval(pos);
```
14 changes: 11 additions & 3 deletions examples/data-objects/table-document/src/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct";
import { IEvent, IFluidHandle } from "@fluidframework/core-interfaces";
import { ICombiningOp, ReferencePosition, PropertySet } from "@fluidframework/merge-tree";
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
import { IntervalType, SequenceDeltaEvent } from "@fluidframework/sequence";
import {
IntervalType,
SequenceDeltaEvent,
SharedString,
createEndpointIndex,
} from "@fluidframework/sequence";
import {
positionToRowCol,
rowColToPosition,
Expand Down Expand Up @@ -77,9 +82,12 @@ export class TableDocument extends DataObject<{ Events: ITableDocumentEvents }>
this.matrix.setItems(row, col, [value], properties);
}

public async getRange(label: string) {
public async getRange(label: string): Promise<CellRange> {
const endpointIndex = createEndpointIndex(this.matrix as unknown as SharedString);
const intervals = this.matrix.getIntervalCollection(label);
const interval = intervals.nextInterval(0);
intervals.attachIndex(endpointIndex);
const interval = endpointIndex.nextInterval(0);
intervals.detachIndex(endpointIndex);
return new CellRange(interval, this.localRefToRowCol);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/dds/sequence/api-report/sequence.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ export interface IIntervalCollection<TInterval extends ISerializableInterval> ex
// (undocumented)
getIntervalById(id: string): TInterval | undefined;
map(fn: (interval: TInterval) => void): void;
// (undocumented)
// @deprecated (undocumented)
nextInterval(pos: number): TInterval | undefined;
// (undocumented)
// @deprecated (undocumented)
previousInterval(pos: number): TInterval | undefined;
removeIntervalById(id: string): TInterval | undefined;
}
Expand Down
21 changes: 21 additions & 0 deletions packages/dds/sequence/src/intervalCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -939,8 +939,29 @@ export interface IIntervalCollection<TInterval extends ISerializableInterval>
*/
map(fn: (interval: TInterval) => void): void;

/**
* @deprecated - due to the forthcoming change where the endpointIndex will no longer be
clarenceli-msft marked this conversation as resolved.
Show resolved Hide resolved
* automatically added to the collection. Users are advised to independently attach the
* index to the collection and utilize the API accordingly, for instance:
* ```typescript
* const endpointIndex = createEndpointIndex(sharedString);
* collection.attachIndex(endpointIndex);
* const result1 = endpointIndex.previousInterval(pos);
* ```
* If an index is used repeatedly, applications should generally attach it once and store it in memory.
*/
clarenceli-msft marked this conversation as resolved.
Show resolved Hide resolved
previousInterval(pos: number): TInterval | undefined;

/**
* @deprecated - due to the forthcoming change where the endpointIndex will no longer be
* automatically added to the collection. Users are advised to independently attach the
* index to the collection and utilize the API accordingly, for instance:
* ```typescript
* const endpointIndex = createEndpointIndex(sharedString);
* collection.attachIndex(endpointIndex);
* const result2 = endpointIndex.nextInterval(pos);
* ```
*/
nextInterval(pos: number): TInterval | undefined;
}

Expand Down