April 2020
Intermediate to advanced
292 pages
6h 50m
English
Now that we have an Aggregator, we need to hook it up to the live flow of messages. An Aggregator is meant to be constantly running, picking up messages more or less as they occur. To hook this one up to that flow, we head back to the top-level function:
| 1: | function build ({ db, messageStore }) { |
| - | const queries = createQueries({ db }) |
| - | const handlers = createHandlers({ queries }) |
| - | const subscription = messageStore.createSubscription({ |
| 5: | streamName: 'viewing', |
| - | handlers, |
| - | subscriberId: 'aggregators:home-page' |
| - | }) |
| - | |
| 10: | function init () { |
| - | return queries.ensureHomePage() |
| - | } |
| - | |
| - | function start () { |
| 15: | init().then(subscription.start) ... |
Read now
Unlock full access