@fluidframework/cell 2.0.0-internal.2.2.1 → 2.0.0-internal.2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +5 -1
- package/README.md +95 -1
- package/dist/cell.d.ts +30 -69
- package/dist/cell.d.ts.map +1 -1
- package/dist/cell.js +34 -69
- package/dist/cell.js.map +1 -1
- package/dist/cellFactory.d.ts +18 -1
- package/dist/cellFactory.d.ts.map +1 -1
- package/dist/cellFactory.js +18 -1
- package/dist/cellFactory.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +70 -3
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/cell.d.ts +30 -69
- package/lib/cell.d.ts.map +1 -1
- package/lib/cell.js +34 -69
- package/lib/cell.js.map +1 -1
- package/lib/cellFactory.d.ts +18 -1
- package/lib/cellFactory.d.ts.map +1 -1
- package/lib/cellFactory.js +18 -1
- package/lib/cellFactory.js.map +1 -1
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -1
- package/lib/interfaces.d.ts +70 -3
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +13 -12
- package/src/cell.ts +54 -87
- package/src/cellFactory.ts +20 -3
- package/src/index.ts +6 -0
- package/src/interfaces.ts +77 -4
- package/src/packageVersion.ts +1 -1
package/src/index.ts
CHANGED
|
@@ -3,5 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* The `SharedCell` Distributed Data Structure (DDS) stores a single, shared value that can be edited or deleted.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
|
|
6
12
|
export { SharedCell } from "./cell";
|
|
7
13
|
export { ISharedCell, ISharedCellEvents } from "./interfaces";
|
package/src/interfaces.ts
CHANGED
|
@@ -6,15 +6,75 @@
|
|
|
6
6
|
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
7
7
|
import { Serializable } from "@fluidframework/datastore-definitions";
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Events emitted by {@link ISharedCell}.
|
|
11
|
+
*/
|
|
9
12
|
export interface ISharedCellEvents<T> extends ISharedObjectEvents {
|
|
13
|
+
/**
|
|
14
|
+
* Emitted when the value has changed.
|
|
15
|
+
*
|
|
16
|
+
* @remarks Event paramters:
|
|
17
|
+
*
|
|
18
|
+
* - `value`: The new value of the cell.
|
|
19
|
+
*/
|
|
10
20
|
(event: "valueChanged", listener: (value: Serializable<T>) => void);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Emitted when the value has been deleted.
|
|
24
|
+
*/
|
|
11
25
|
(event: "delete", listener: () => void);
|
|
12
26
|
}
|
|
13
27
|
|
|
14
28
|
/**
|
|
15
|
-
*
|
|
29
|
+
* A Distributed Data Structure (DDS), which stores a single shared value that can be edited or deleted.
|
|
30
|
+
*
|
|
31
|
+
* @typeParam T - The type of cell data. Must be serializable.
|
|
32
|
+
*
|
|
33
|
+
* @example Creation:
|
|
34
|
+
*
|
|
35
|
+
* To create a `SharedCell`, call the static create method:
|
|
36
|
+
*
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const myCell = SharedCell.create(this.runtime, id);
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example Usage:
|
|
42
|
+
*
|
|
43
|
+
* The value stored in the cell can be set with the `.set()` method and retrieved with the `.get()` method:
|
|
44
|
+
*
|
|
45
|
+
* ```typescript
|
|
46
|
+
* myCell.set(3);
|
|
47
|
+
* console.log(myCell.get()); // 3
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* The value must only be plain JS objects or `SharedObject` handles (e.g. to another DDS or Fluid object).
|
|
51
|
+
* In collaborative scenarios, the value is settled with a policy of _last write wins_.
|
|
52
|
+
*
|
|
53
|
+
* The `.delete()` method will delete the stored value from the cell:
|
|
54
|
+
*
|
|
55
|
+
* ```typescript
|
|
56
|
+
* myCell.delete();
|
|
57
|
+
* console.log(myCell.get()); // undefined
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* The `.empty()` method will check if the value is undefined.
|
|
61
|
+
*
|
|
62
|
+
* ```typescript
|
|
63
|
+
* if (myCell.empty()) {
|
|
64
|
+
* // myCell.get() will return undefined
|
|
65
|
+
* } else {
|
|
66
|
+
* // myCell.get() will return a non-undefined value
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example Eventing:
|
|
71
|
+
*
|
|
72
|
+
* `SharedCell` is an `EventEmitter`, and will emit events when other clients make modifications. You should
|
|
73
|
+
* register for these events and respond appropriately as the data is modified. `valueChanged` will be emitted
|
|
74
|
+
* in response to a `set`, and `delete` will be emitted in response to a `delete`.
|
|
16
75
|
*/
|
|
17
|
-
|
|
76
|
+
// TODO: use `unknown` instead (breaking change).
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
78
|
export interface ISharedCell<T = any> extends ISharedObject<ISharedCellEvents<T>> {
|
|
19
79
|
/**
|
|
20
80
|
* Retrieves the cell value.
|
|
@@ -42,7 +102,20 @@ export interface ISharedCell<T = any> extends ISharedObject<ISharedCellEvents<T>
|
|
|
42
102
|
*/
|
|
43
103
|
delete(): void;
|
|
44
104
|
}
|
|
45
|
-
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Describes a local Cell operation (op).
|
|
108
|
+
*/
|
|
109
|
+
// TODO: use `unknown` instead.
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
|
+
export interface ICellLocalOpMetadata<T = any> {
|
|
112
|
+
/**
|
|
113
|
+
* Unique identifier for this local operation (op).
|
|
114
|
+
*/
|
|
46
115
|
pendingMessageId: number;
|
|
47
|
-
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The value of the {@link ISharedCell} prior to this operation (op).
|
|
119
|
+
*/
|
|
120
|
+
previousValue?: Serializable<T> ;
|
|
48
121
|
}
|
package/src/packageVersion.ts
CHANGED