pull/2843/merge
Tony 3 days ago committed by GitHub
commit 2221eac9d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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. * 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 * @returns
*/ */
reload(): Promise<void> reload(): Promise<void>

@ -284,6 +284,8 @@ impl<R: Runtime> StoreInner<R> {
} }
/// Update the store from the on-disk state /// 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<()> { pub fn load(&mut self) -> crate::Result<()> {
let bytes = fs::read(&self.path)?; let bytes = fs::read(&self.path)?;
@ -499,6 +501,12 @@ impl<R: Runtime> Store<R> {
} }
/// Update the store from the on-disk state /// 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<()> { pub fn reload(&self) -> crate::Result<()> {
self.store.lock().unwrap().load() self.store.lock().unwrap().load()
} }

Loading…
Cancel
Save