April 2020
Intermediate to advanced
292 pages
6h 50m
English
read and readLastMessage both sit inside a top-level dependency-receiving function that receives a db reference. Let’s open code/video-tutorials/src/message-store/index.js and pull these functions in:
| | const createRead = require('./read') |
| | const configureCreateSubscription = require('./subscribe') |
| | // ... |
| | function createMessageStore ({ db }) { |
| | // ... |
| | const read = createRead({ db }) |
| | const createSubscription = configureCreateSubscription({ |
| | read: read.read, |
| | readLastMessage: read.readLastMessage, |
| | write: write |
| | }) |
| | return { |
| | // ... |
| | createSubscription, |
| | read: read.read, |
| | readLastMessage: read.readLastMessage, ... |