This repository was archived by the owner on Feb 4, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ import { Tree } from "./Tree";
20
20
import { TreeNode } from "./TreeNode" ;
21
21
import mitt from "mitt" ;
22
22
23
- type Events < Id , Metadata > = {
23
+ export type Events < Id , Metadata > = {
24
24
/**
25
25
* Intermediary operations made when reordering events based on timestamps.
26
26
*
@@ -34,7 +34,7 @@ type Events<Id, Metadata> = {
34
34
} ;
35
35
} ;
36
36
37
- type Parent < Id , Metadata > = {
37
+ export type Parent < Id , Metadata > = {
38
38
id : Id ;
39
39
metadata ?: Metadata ;
40
40
parent ?: Parent < Id , Metadata > ;
Original file line number Diff line number Diff line change 10
10
// `State` is a lower-level interface to the Tree CRDT and is not tied to any
11
11
// actor/peer.
12
12
13
+ import { Emitter } from "mitt" ;
13
14
import { Clock } from "./Clock" ;
14
15
import { OpMove } from "./OpMove" ;
15
- import { State } from "./State" ;
16
+ import { Events , State } from "./State" ;
16
17
import { Tree } from "./Tree" ;
17
18
import { TreeNode } from "./TreeNode" ;
18
19
@@ -39,11 +40,15 @@ export class TreeReplica<Id, Metadata> {
39
40
latestTimeByReplica : Map < Id , Clock < Id > > = new Map ( ) ;
40
41
/** A tree structure that represents the current state of the tree */
41
42
tree : Tree < Id , Metadata > ;
43
+ /** An event emitter for updates to the state of the tree */
44
+ emitter : Emitter < Events < Id , Metadata > > ;
42
45
43
46
constructor ( authorId : Id , options : ReplicaOptions < Id , Metadata > = { } ) {
44
47
this . time = new Clock ( authorId ) ;
45
48
this . state = new State ( options ) ;
49
+
46
50
this . tree = this . state . tree ;
51
+ this . emitter = this . state . emitter ;
47
52
}
48
53
49
54
/** Get a node by its id */
You can’t perform that action at this time.
0 commit comments