Flattens a stream of streams. The result stream reflects changes from the last stream only.
Graph
a: {--.----.----}
{ab} {a-b}
switchLatest(a): {--ab---a-b--}
Signature
Stream (Stream a) -> Stream b
Usage
const switchLatest = require('flyd/module/switchlatest')
const chatrooms = flyd.stream()
// For each chatroom on the chatrooms stream, create a stream of chat messages.
// This gives us a series of streams nested within a parent stream.
const messages = flyd.map(createMessageStream, chatrooms)
// Create a single, unnested stream of chat messages
const currentMessages = switchLatest(messagesStreams)