How to use watch() on web SDK?

I totally agree, we’re still missing a good example on using this.

Calling watch on a collection returns an AsyncIterable (an object with the Symbol.asyncIterator property). More specifically watch is an async generator function, which means that the iterable it returns is also a Generator: Calling the return() method on this will break the loop and close the underlying connection.

If you have opinions about this API, I encourage you to voice it on Alternative MongoDB Watch API · Issue #3259 · realm/realm-js · GitHub and https://twitter.com/kraenhansen/status/1313136226246053890.

1 Like