Rust implementation of NextGraph, a Decentralized and local-first web 3.0 ecosystem https://nextgraph.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nextgraph-rs/ng-app/src/store.ts

33 lines
899 B

import { writable } from "svelte/store";
import ng from "./api";
const branch_commits = (nura, sub) => {
const { subscribe, set, update } = writable([]); // create the underlying writable store
let unsub = () => {};
return {
load: async () => {
unsub = await ng.doc_sync_branch(nura, async (commit) => {
console.log(commit);
update( (old) => {old.unshift(commit); return old;} )
});
},
subscribe: (run, invalid) => {
let upper_unsub = subscribe(run, invalid);
return () => {
upper_unsub();
unsub();
}
}
// set: (value) => {
// localStorage.setItem(key, toString(value)); // save also to local storage as a string
// return set(value);
// },
// update,
};
};
export default branch_commits;