From bf908ecfe754f1a61a94d4c432ed3980808b286f Mon Sep 17 00:00:00 2001 From: Jacob Bolda Date: Tue, 14 Oct 2025 12:34:27 -0500 Subject: [PATCH 1/2] webhook example shows two matcher examples --- packages/foundation/example/pingback/server-two.ts | 8 ++++---- packages/foundation/tests/webhook.test.ts | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/foundation/example/pingback/server-two.ts b/packages/foundation/example/pingback/server-two.ts index b3830b0d..46ecad3d 100644 --- a/packages/foundation/example/pingback/server-two.ts +++ b/packages/foundation/example/pingback/server-two.ts @@ -67,14 +67,14 @@ export function simulation(): FoundationSimulator { // ); // to avoid the double call from the two watchers // skip this one - // yield* put(bappedTrigger()); + yield* put(bappedTrigger()); } }); } // using take and your own iteration loop is another method of doing of listening for events function* boopWatcherOptionTwo() { - while (true) { - const action = yield* take("*"); + // this `*` will match all actions and you can filter inside + yield* takeEvery("*", function* (action) { if (isBoopEvent(action)) { // console.dir( // { @@ -86,7 +86,7 @@ export function simulation(): FoundationSimulator { // ); yield* put(bappedTrigger()); } - } + }); } return { diff --git a/packages/foundation/tests/webhook.test.ts b/packages/foundation/tests/webhook.test.ts index 855276ac..8c490052 100644 --- a/packages/foundation/tests/webhook.test.ts +++ b/packages/foundation/tests/webhook.test.ts @@ -52,8 +52,8 @@ describe("pingback", () => { // check the webhook listener is gets double incremented let r7 = await f(`${urlOne}/get/bap`); // note that we have two watchers - // but only one sends the increment request - expect(r7).toEqual({ count: 1 }); + // and each webhook event triggers both watchers + expect(r7).toEqual({ count: 2 }); // trigger via external endpoint on one // which will webhook to the other @@ -68,6 +68,6 @@ describe("pingback", () => { // our watcher has updated the bapped count though let r11 = await f(`${urlOne}/get/bap`); - expect(r11).toEqual({ count: 2 }); // ie see r9 vs r11 + expect(r11).toEqual({ count: 4 }); // ie see r9 vs r11 }); }); From 798359946555aa1bd902d4f3cccb57b043fe6ac5 Mon Sep 17 00:00:00 2001 From: Jacob Bolda Date: Tue, 14 Oct 2025 12:53:54 -0500 Subject: [PATCH 2/2] lint --- packages/foundation/example/pingback/server-two.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/foundation/example/pingback/server-two.ts b/packages/foundation/example/pingback/server-two.ts index 46ecad3d..e5fe72fa 100644 --- a/packages/foundation/example/pingback/server-two.ts +++ b/packages/foundation/example/pingback/server-two.ts @@ -1,4 +1,4 @@ -import { put, take, takeEvery, type Action } from "starfx"; +import { put, takeEvery, type Action } from "starfx"; import { createFoundationSimulationServer } from "../../src/index.ts"; import type { ExtendSimulationSchema,