Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an interface to subscribe to root CID changes #414

Open
bgins opened this issue Aug 22, 2022 · 1 comment
Open

Add an interface to subscribe to root CID changes #414

bgins opened this issue Aug 22, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@bgins
Copy link
Member

bgins commented Aug 22, 2022

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
Copy link
Member Author

bgins commented Aug 22, 2022

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

  • Add an event emitter that emits local and remote change events
  • Make the event emitter available to developers at webnative initialization
  • Emit local events based on existing publish hooks
  • After each local event, poll internally for remote changes and and emit an event when change is confirmed remotely

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant