jfroelich / rss-reader

A simple Chrome extension for viewing RSS feeds
Other
10 stars 0 forks source link

The upgrade handler should generate channel messages #785

Closed jfroelich closed 5 years ago

jfroelich commented 5 years ago

If it is modifying data that normally is accompanied by channel messages, then it should also send messages. This means db depends on channel, it is not associative.

jfroelich commented 5 years ago

Essentially, db/open should accept a channel parameter. It should be optional. Instead of returning a promise that resolves to an IDBDatabase instance, it resolves to a connection instance. The instance has two props, conn (IDBDatabase) and channel (channel). Then all methods accept the Connection instance instead of the IDBDatabase instance, and no longer accept the channel instance.

except that maybe channel cannot be optional, because any read transaction can still cause an upgrade. therefore channel should be required even for simple reads.

open should accept either the channel name parameter and construct its own channel, or it should accept an instance of a channel object.

consider implementing a custom type, Channel, that by default is a BroadcastChannel. Or channel is an interface, and a BroadcastChannel is just one implementation of that interface.