11. Merge: Latest
Lesson 11: Merge: Latest
Sometimes you don't need a full list - just the most recent events. That's what merge: 'latest' does.
It works like a ring buffer: new events push in, old ones fall off when the buffer is full.
live.stream('feed', () => entries, {
merge: 'latest',
max: 10 // keep only the last 10
}); This is perfect for activity feeds, notification lists, or event logs where you only care about recent history.
Try it
- Create an
addEntryRPC that takes atextparameter - Each entry should have an
id(usecrypto.randomUUID()),text, andtimestamp(useDate.now()) - Create a
feedstream withmerge: 'latest'andmax: 10
WebSocket
0
No messages yet