Skip to content

Commit b8618ed

Browse files
christianalfoniCompuIves
authored andcommitted
Fix issue with reaction (#2502)
1 parent 5294b9b commit b8618ed

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

packages/app/src/app/overmind/createConnect.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@ const IS_PRODUCTION = process.env.NODE_ENV === 'production';
2525
function createReaction(overmind: any) {
2626
return (reactionCb: any, updateCb: any) => {
2727
const tree = overmind.proxyStateTree.getTrackStateTree();
28+
const updateReaction = () => {
29+
tree.trackScope(
30+
() => reactionCb(tree.state),
31+
() => {
32+
updateCb(reactionCb(tree.state));
33+
updateReaction();
34+
}
35+
);
36+
};
2837

29-
tree.trackScope(
30-
() => reactionCb(tree.state),
31-
() => updateCb(reactionCb(tree.state))
32-
);
38+
updateReaction();
3339

3440
return () => {
3541
overmind.proxyStateTree.disposeTree(tree);

packages/app/src/app/overmind/effects/live/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ export default {
151151
.receive('ok', resolve)
152152
.receive('error', reject);
153153
} else {
154-
// eslint-disable-next-line prefer-promise-reject-errors
155-
reject('Channel is not defined');
154+
// we might try to send messages even when not on live, just
155+
// ignore it
156+
resolve();
156157
}
157158
});
158159
},

0 commit comments

Comments
 (0)