Skip to content

Commit bf908ec

Browse files
committed
webhook example shows two matcher examples
1 parent c30de63 commit bf908ec

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

packages/foundation/example/pingback/server-two.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ export function simulation(): FoundationSimulator<any> {
6767
// );
6868
// to avoid the double call from the two watchers
6969
// skip this one
70-
// yield* put(bappedTrigger());
70+
yield* put(bappedTrigger());
7171
}
7272
});
7373
}
7474
// using take and your own iteration loop is another method of doing of listening for events
7575
function* boopWatcherOptionTwo() {
76-
while (true) {
77-
const action = yield* take("*");
76+
// this `*` will match all actions and you can filter inside
77+
yield* takeEvery("*", function* (action) {
7878
if (isBoopEvent(action)) {
7979
// console.dir(
8080
// {
@@ -86,7 +86,7 @@ export function simulation(): FoundationSimulator<any> {
8686
// );
8787
yield* put(bappedTrigger());
8888
}
89-
}
89+
});
9090
}
9191

9292
return {

packages/foundation/tests/webhook.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ describe("pingback", () => {
5252
// check the webhook listener is gets double incremented
5353
let r7 = await f(`${urlOne}/get/bap`);
5454
// note that we have two watchers
55-
// but only one sends the increment request
56-
expect(r7).toEqual({ count: 1 });
55+
// and each webhook event triggers both watchers
56+
expect(r7).toEqual({ count: 2 });
5757

5858
// trigger via external endpoint on one
5959
// which will webhook to the other
@@ -68,6 +68,6 @@ describe("pingback", () => {
6868

6969
// our watcher has updated the bapped count though
7070
let r11 = await f(`${urlOne}/get/bap`);
71-
expect(r11).toEqual({ count: 2 }); // ie see r9 vs r11
71+
expect(r11).toEqual({ count: 4 }); // ie see r9 vs r11
7272
});
7373
});

0 commit comments

Comments
 (0)