9: Reading feed data from multifeed

Now that we have created a multifeed, each hypercore represents a different user in the application. When we replicate with another multifeed peer, we download their feeds and upload ours.

multifeed.feeds() returns a list of feeds, which are just hypercore objects (ie. they each have a createReadStream() function)..

multi.ready(function () {
  const feeds = multi.feeds()

  // iterate over each feed that exists locally..
  feeds.forEach(function (feed) {
    // feed is a hypercore! (remember reading from hypercores in previous exercises?)
    // TODO: feed.createReadStream
  })

  // listen for new feeds that might be shared with us during runtime..
  multi.on('feed', function (feed) {
    // TODO: feed.createReadStream
  })
})

Exercise

Using console.log, write all chat messages to the screen from every hypercore in the multifeed. Have it iterate over all chat messages from all hypercores.

Tips

Once you solve this exercise continue to exercise 10a