forked from NextGraph/nextgraph-rs
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.
33 lines
899 B
33 lines
899 B
2 years ago
|
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;
|