Open btimby opened 3 years ago
Tons of progress now, all orbitdb functionality is now in a top-level orbitdb.js
module, and uses the plugin. At a high-level, the orbitdb plugin allows you to subscribe to pubsub as well as databases. When data arrives, it can be pushed to vuex. On the other hand, the orbitdb plugin subscribes to vuex mutations, and can keep orbitdb up-to-date with vuex.
https://github.com/btimby/nimtok/blob/main/src/orbitdb.js
This way Vue components only write to vuex and orbitdb is kept synchronized. When events arrive from orbitdb, vuex is synchronized and components react.
I am pretty happy with the result so far, I also moved some unrelated state management into components and out of vuex, so vuex ONLY handles the global state.
I added avoidance for circular synchronization, for example:
I want to abstract this, so that whenver orbitdb sends a mutation, the payload includes a flag (that is NOT written to the vuex store). The flag should be used to skip sync in the store subscription handler.
Implement global property:
this.$orbitdb...
Ala vue-router:
https://github.com/vuejs/vue-router/blob/dev/src/install.js#L21
Add an easier way to query, currently I do:
dbname = await orbitdb.open('dbname', 'dbtype');
dbname.db.events.on('ready', () => {
...
await dbname.db.close();
});
await dbname.db.load();
The above is for one-off queries.
Add a way to "follow" a feed or log database, on received event, advance the cursor and dispatch and action for new items.
See: https://github.com/orbitdb/orbit-db/blob/master/API.md#iteratoroptions
I think my Vue plugin VueOrbitDB is abstract and useful enough to stand alone.
https://github.com/btimby/nimtok/blob/main/src/plugins/orbitdb.js
It has the following benefits: