File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 1- import { put , take , takeEvery , type Action } from "starfx" ;
1+ import { put , takeEvery , type Action } from "starfx" ;
22import { createFoundationSimulationServer } from "../../src/index.ts" ;
33import type {
44 ExtendSimulationSchema ,
@@ -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 {
Original file line number Diff line number Diff 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} ) ;
You can’t perform that action at this time.
0 commit comments