From cd03dec5b010753af776f6194670d29f3b67bc92 Mon Sep 17 00:00:00 2001 From: Peter van Hardenberg Date: Tue, 23 Jul 2024 17:36:16 -0700 Subject: [PATCH] remove an unused CREATE action and rename the remaining FIND to BEGIN, since it is always run --- packages/automerge-repo/src/DocHandle.ts | 33 ++++++++++++------------ 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/packages/automerge-repo/src/DocHandle.ts b/packages/automerge-repo/src/DocHandle.ts index 4b2a3c2d..62610b67 100644 --- a/packages/automerge-repo/src/DocHandle.ts +++ b/packages/automerge-repo/src/DocHandle.ts @@ -91,8 +91,7 @@ export class DocHandle extends EventEmitter> { states: { idle: { on: { - CREATE: "ready", - FIND: "loading", + BEGIN: "loading", }, }, loading: { @@ -132,7 +131,7 @@ export class DocHandle extends EventEmitter> { // Start the machine, and send a create or find event to get things going this.#machine.start() - this.#machine.send({ type: FIND }) + this.#machine.send({ type: BEGIN }) } // PRIVATE @@ -448,19 +447,19 @@ export class DocHandle extends EventEmitter> { export type DocHandleOptions = // NEW DOCUMENTS | { - /** If we know this is a new document (because we're creating it) this should be set to true. */ - isNew: true + /** If we know this is a new document (because we're creating it) this should be set to true. */ + isNew: true - /** The initial value of the document. */ - initialValue?: T - } + /** The initial value of the document. */ + initialValue?: T + } // EXISTING DOCUMENTS | { - isNew?: false + isNew?: false - /** The number of milliseconds before we mark this document as unavailable if we don't have it and nobody shares it with us. */ - timeoutDelay?: number - } + /** The number of milliseconds before we mark this document as unavailable if we don't have it and nobody shares it with us. */ + timeoutDelay?: number + } // EXTERNAL EVENTS @@ -561,18 +560,18 @@ interface DocHandleContext { /** These are the (internal) events that can be sent to the state machine */ type DocHandleEvent = - | { type: typeof FIND } + | { type: typeof BEGIN } | { type: typeof REQUEST } | { type: typeof DOC_READY } | { - type: typeof UPDATE - payload: { callback: (doc: A.Doc) => A.Doc } - } + type: typeof UPDATE + payload: { callback: (doc: A.Doc) => A.Doc } + } | { type: typeof TIMEOUT } | { type: typeof DELETE } | { type: typeof DOC_UNAVAILABLE } -const FIND = "FIND" +const BEGIN = "BEGIN" const REQUEST = "REQUEST" const DOC_READY = "DOC_READY" const UPDATE = "UPDATE"