From aa5ab871a5157dd70d55768843aeeab521258a49 Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Wed, 3 Jul 2024 22:29:13 +0330 Subject: [PATCH] feat: Add saveImmediate method to CollectionReference and DocumentReference The code changes add a new method called `saveImmediate` to both the `CollectionReference` and `DocumentReference` classes. This method allows the Alwatr Store to save the collection or document immediately, bypassing any debounce delay. The purpose of this change is to provide a way to save the data without any delay when immediate saving is required. --- .../reference/src/collection-reference.ts | 33 +++++++++++++++---- packages/reference/src/document-reference.ts | 33 +++++++++++++++---- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/packages/reference/src/collection-reference.ts b/packages/reference/src/collection-reference.ts index 30cf80f5..eccb83a1 100644 --- a/packages/reference/src/collection-reference.ts +++ b/packages/reference/src/collection-reference.ts @@ -419,16 +419,27 @@ export class CollectionReference> { this.logger__.logMethod?.('getFullContext_'); return this.context__; @@ -514,7 +535,7 @@ export class CollectionReference { - this.logger__.logMethodArgs?.('updated__', {delayed: this.updateDelayed_}); + this.logger__.logMethodArgs?.('updated__', {id, immediate, delayed: this.updateDelayed_}); this.hasUnprocessedChanges_ = true; if (id !== null) this.updateMeta_(id); // meta must updated per item diff --git a/packages/reference/src/document-reference.ts b/packages/reference/src/document-reference.ts index 20f42f81..44c09d21 100644 --- a/packages/reference/src/document-reference.ts +++ b/packages/reference/src/document-reference.ts @@ -268,18 +268,39 @@ export class DocumentReference> { this.logger__.logMethod?.('getFullContext_'); return this.context__; @@ -292,7 +313,7 @@ export class DocumentReference { - this.logger__.logMethodArgs?.('updated__', {delayed: this.updateDelayed_}); + this.logger__.logMethodArgs?.('updated__', {immediate, delayed: this.updateDelayed_}); this.hasUnprocessedChanges_ = true;