oddsdk / ts-odd

An SDK for building apps with decentralized identity and storage.
https://odd.dev/
Apache License 2.0
178 stars 24 forks source link

Add an interface to subscribe to root CID changes #414

Open bgins opened 2 years ago

bgins commented 2 years ago

Summary

Problem

Developers need to poll the filesystem to detect changes.

Impact

Extra work and complexity for developers.

Solution

Add an interface to subscribe to any change to WNFS. The interface should notify developers when a change occurs locally and remotely.

Detail

It's currently possible to add a callback to the WNFS publish hooks, which are called when a change is made locally. We can likely use the existing work as a starting point or hook into it.

bgins commented 2 years ago

A couple of rough ideas for how we might implement this feature:

Note that this would be a first quick implementation with a focus on getting it working and establishing a good interface. A subsequent implementation could set up PubSub with the server over a websockets channel to remove the internal polling.