From c4d8ea515a20b3af106984c31e2e4f74c470a5aa Mon Sep 17 00:00:00 2001 From: Tony Date: Sat, 12 Jul 2025 15:45:35 +0800 Subject: [PATCH] docs(store): reload merges the value --- plugins/store/guest-js/index.ts | 7 ++++++- plugins/store/src/store.rs | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/store/guest-js/index.ts b/plugins/store/guest-js/index.ts index 1df89fd5..4cf1c9b2 100644 --- a/plugins/store/guest-js/index.ts +++ b/plugins/store/guest-js/index.ts @@ -396,7 +396,12 @@ interface IStore { * * This method is useful if the on-disk state was edited by the user and you want to synchronize the changes. * - * Note: This method does not emit change events. + * Note: + * - This method loads the data and merges it with the current store, + * this behavior will be changed to overriding from on-disk state in v3, + * for now, call {@linkcode clear} first for the store to fully match the on-disk state + * - This method does not emit change events. + * * @returns */ reload(): Promise diff --git a/plugins/store/src/store.rs b/plugins/store/src/store.rs index 1dc5e1d2..421dd00e 100644 --- a/plugins/store/src/store.rs +++ b/plugins/store/src/store.rs @@ -284,6 +284,8 @@ impl StoreInner { } /// Update the store from the on-disk state + /// + /// Note: This method loads the data and merges it with the current store pub fn load(&mut self) -> crate::Result<()> { let bytes = fs::read(&self.path)?; @@ -499,6 +501,12 @@ impl Store { } /// Update the store from the on-disk state + /// + /// Note: + /// - This method loads the data and merges it with the current store, + /// this behavior will be changed to overriding from on-disk state in v3, + /// for now, call [`clear`](Self::clear) first for the store to fully match the on-disk state + /// - This method does not emit change events pub fn reload(&self) -> crate::Result<()> { self.store.lock().unwrap().load() }