Skip to content

Commit

Permalink
fix: can now publish to the message bus after receiving values from it
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed Dec 2, 2024
1 parent 59ef7d2 commit 2871b1a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ export function map(channel, topic, initialValue) {
// To avoid an infinite loop we fire this only when the source of the change is the app, not the message bus.
if (source !== 'bus') {
messageBus.publish(channel, topic, value);
} else {
// We got this change from the message bus.
// Revert to assuming we publish changes now that we're done writing.
source = 'app';
}
});

Expand Down Expand Up @@ -181,6 +185,10 @@ export function deepMap(channel, topic, initialValue) {
// To avoid an infinite loop we fire this only when the source of the change is the app, not the message bus.
if (source !== 'bus') {
messageBus.publish(channel, topic, value);
} else {
// We got this change from the message bus.
// Revert to assuming we publish changes now that we're done writing.
source = 'app';
}
});

Expand Down

0 comments on commit 2871b1a

Please sign in to comment.