DEV Community

Discussion on: Serverless Background Tasks with OpenJS Architect - Part 1

Collapse
 
snelgrove profile image
snelgrove

Nice tutorial. I agreee that events would be great for a one-to-many pattern, but I can't work out how arc lets you do that. /src/events/yolo defines one lambda function that is subscribed to yolo, but the event is derived from the path. How would you create a second function subscribed to the yolo event?

Collapse
 
pchinjr profile image
Paul Chin Jr.

You would still keep a single event mapped to one event function, but in the POST lambda you could publish to multiple event functions. For example, a single POST request would publish in parallel to two different event topics like a newsletter signup service and saving their information to a database. I hope that makes sense.

Collapse
 
snelgrove profile image
snelgrove

That makes sense. I was thinking along the lines of a more general "new-user" event, with two subscribers "newsletter signup" and "save to database".