Add note about infinite loop
This commit is contained in:
@@ -53,12 +53,16 @@ export class StoreComposite extends BaseStore {
|
||||
for (const remoteStore of this.remoteStores) {
|
||||
remoteStore.on('set', async (payload) => {
|
||||
// Skip if the local store already has the key
|
||||
// NOTE: It's important we DO NOT repropagate events that have already occurred.
|
||||
// If we do, we can end up in infinite loops.
|
||||
if (await this.localStore.has(payload.key)) return;
|
||||
|
||||
await this.localStore.set(payload.key, payload.value);
|
||||
});
|
||||
|
||||
remoteStore.on('delete', async (payload) => {
|
||||
// NOTE: It's important we DO NOT repropagate events that have already occurred.
|
||||
// If we do, we can end up in infinite loops.
|
||||
if (await this.localStore.has(payload.key)) {
|
||||
await this.localStore.delete(payload.key);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user