Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
fix: export IntermediaryOp type
Browse files Browse the repository at this point in the history
  • Loading branch information
matchai committed Aug 11, 2021
1 parent 4ee1ca3 commit 4e69884
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ export type Events<Id, Metadata> = {
* This is useful when mirroring the state of `crdt-tree` to another
* stateful representation.
* */
intermediaryOp: {
id: Id;
metadata: Metadata;
parent?: Parent<Id, Metadata>;
};
intermediaryOp: IntermediaryOp<Id, Metadata>;
};

export type IntermediaryOp<Id, Metadata> = {
id: Id;
metadata: Metadata;
parent?: Parent<Id, Metadata>;
};

export type Parent<Id, Metadata> = {
Expand Down Expand Up @@ -152,7 +154,7 @@ export class State<Id, Metadata> {
this.emitter.emit("intermediaryOp", {
id: op.id,
metadata: op.metadata,
parent: this.flattenTree(op.parentId, this.tree)
parent: this.flattenTree(op.parentId, this.tree),
});
return { op, oldNode };
}
Expand All @@ -168,7 +170,7 @@ export class State<Id, Metadata> {
this.emitter.emit("intermediaryOp", {
id: log.op.id,
metadata: log.op.metadata,
parent: log.oldNode && this.flattenTree(log.oldNode?.parentId, this.tree)
parent: log.oldNode && this.flattenTree(log.oldNode?.parentId, this.tree),
});
}

Expand All @@ -194,7 +196,7 @@ export class State<Id, Metadata> {
return {
id: parentId,
metadata: tree.get(parentId)?.metadata,
parent: ancestorId && this.flattenTree(ancestorId, tree)
parent: ancestorId && this.flattenTree(ancestorId, tree),
};
}
}

0 comments on commit 4e69884

Please sign in to comment.