April 2020
Intermediate to advanced
292 pages
6h 50m
English
In code/video-tutorials/src/message-store/subscribe.js we wrote getNextBatchOfMessages which retrieves the batches of messages in the category we’re subscribing to. For subscriptions that have an originStreamName, we’ll further filter that query result based on whether or not the messages have that originStreamName in their metadata.
First the filtering function:
| 1: | const category = require('./category') |
| - | function configureCreateSubscription ({ read, readLastMessage, write }) { |
| - | // ... |
| - | function filterOnOriginMatch (messages) { |
| 5: | if (!originStreamName) { |
| - | return messages |
| - | } |
| - | |
| - | return messages.filter(message => { |
| 10: ... |