fro.profesional
fro.profesional7mo ago

deno kv watch vs broadcast channel

For creating a chat app for example, which one should i use? What are the differences? Kv watch gets triggered even if no isolate is alive?
4 Replies
Deno AI Helper
Deno AI Helper7mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on your message, I can provide some general insights that might help you decide between Deno.KV.watch and BroadcastChannel. Deno.KV.watch is a feature that allows you to watch for changes on a given key in Deno's key-value storage. When a key is updated, a watcher can be notified of this change. This can be useful for synchronizing state across different parts of your application or across different instances of your application. On the other hand, BroadcastChannel is a web standard that allows you to broadcast messages to other scripts that are listening to the same channel. It's typically used for communication between different parts of a web application running in the same browser context, but it can also be used in workers or other environments that support it. For a chat application, you might find BroadcastChannel more suitable if your chat is confined to a single browser context or you are using web workers. It allows for easy message passing between different parts of your application without the need for a backend service to relay messages. Regarding your question about Deno.KV.watch being triggered even if no isolate is alive, I cannot provide a definitive answer as this is not covered in the Deno documentation. However, it's important to note that Deno.KV.watch is likely designed to work with Deno's infrastructure, and its behavior would depend on how Deno's key-value storage is implemented and how it interacts with isolates. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of the advice given. For the most accurate and up-to-date information, you may want to explore
Deno AI Helper
Deno AI Helper7mo ago
the Deno community resources or reach out to the Deno maintainers directly.
Antonio Sampaio
Antonio Sampaio7mo ago
I saw some messages about kv.watch not notifying all events, only the last ones
fro.profesional
fro.profesional6mo ago
I saw some mention in #deploy™ that BroadcastChannel messages doesn’t have guaranteed delivery and kv watch does so I guess for a chat is better kv watch all though I don’t think there are exclusive (can be used and the same time i think)