From 5ecb71a80ed26ecceeb6594c2b23679f82934892 Mon Sep 17 00:00:00 2001 From: zak Date: Tue, 17 Oct 2023 13:09:43 +0100 Subject: [PATCH] Fix doc strings for model and mutation registry Also: - simplify the object namespacing used for model.data.confirmed and model.data.optimistic --- src/Model.ts | 10 ++++++---- src/MutationsRegistry.ts | 10 ---------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/Model.ts b/src/Model.ts index 7fd07e39..79fca61d 100644 --- a/src/Model.ts +++ b/src/Model.ts @@ -93,16 +93,18 @@ export default class Model extends EventEmitter this.optimisticData).bind(this); - const confirmed = (() => this.confirmedData).bind(this); + const self = this; return { get optimistic() { - return optimistic(); + return self.optimisticData; }, get confirmed() { - return confirmed(); + return self.confirmedData; }, }; } diff --git a/src/MutationsRegistry.ts b/src/MutationsRegistry.ts index 1fb48134..60053b57 100644 --- a/src/MutationsRegistry.ts +++ b/src/MutationsRegistry.ts @@ -124,16 +124,6 @@ export default class MutationsRegistry { ); } - /** - * The optimisticEvent function that handles including optimistic events in the model state. - * @param {OptimisticInvocationParams} params - The set of events (params.events) that should be optimistically - * applied to the model state. And optionally a timeout (params.options.timeout) within which a confirmed - * event should be received from the backend, or else the optimistic events will rollback. - * @returns {Promise<[Promise,() => void]>} A Promise that resolves to a [confirmed, cancel] tuple - * when the model has successfully applied the optimistic update. The confirmed field from the tuple is a - * promise that resolves when the optimistic event is confirmed. The cancel field from the tuple is a - * function that can be used to trigger the rollback of the optimistic event. - */ public async handleOptimsitic(params: OptimisticInvocationParams): Promise<[Promise, () => Promise]> { const mergedOptions = this.mergeOptions(params.options, this.options, DEFAULT_OPTIONS);