mirror of
https://github.com/urbit/shrub.git
synced 2025-01-03 18:16:30 +03:00
wip: graph-store JS api
This commit is contained in:
parent
b0fa0668b3
commit
2e5bbd7423
80
pkg/interface/src/api/graph.js
Normal file
80
pkg/interface/src/api/graph.js
Normal file
@ -0,0 +1,80 @@
|
||||
import BaseApi from './base';
|
||||
|
||||
class PrivateHelper extends BaseApi {
|
||||
graphAction(data) {
|
||||
this.action('graph-store', 'graph-action', data);
|
||||
}
|
||||
|
||||
addGraph(resource, graph) {
|
||||
this.graphAction({
|
||||
'add-graph': {
|
||||
resource,
|
||||
graph
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
removeGraph(resource) {
|
||||
this.graphAction({
|
||||
'remove-graph': {
|
||||
resource
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addNodes(resource, nodes) {
|
||||
this.graphAction({
|
||||
'add-nodes': {
|
||||
resource,
|
||||
nodes
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
removeNodes(resource, indices) {
|
||||
this.graphAction({
|
||||
'remove-nodes': {
|
||||
resource,
|
||||
indices
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addSignatures() {
|
||||
this.graphAction();
|
||||
}
|
||||
|
||||
removeSignatures() {
|
||||
this.graphAction();
|
||||
}
|
||||
|
||||
addTag() {
|
||||
this.graphAction();
|
||||
}
|
||||
|
||||
removeTag() {
|
||||
this.graphAction();
|
||||
}
|
||||
}
|
||||
|
||||
export default class GraphApi {
|
||||
constructor(ship, channel, store) {
|
||||
const helper = new PrivateHelper(ship, channel, store);
|
||||
|
||||
this.ship = ship;
|
||||
this.subscribe = helper.subscribe.bind(helper);
|
||||
|
||||
this.addGraph = helper.addGraph.bind(helper);
|
||||
this.removeGraph = helper.removeGraph.bind(helper);
|
||||
|
||||
this.addNodes = helper.addNodes.bind(helper);
|
||||
this.removeNodes = helper.removeNodes.bind(helper);
|
||||
|
||||
this.addSignatures = helper.addSignatures.bind(helper);
|
||||
this.removeSignatures = helper.removeSignatures.bind(helper);
|
||||
|
||||
this.addTag = helper.addTag.bind(helper);
|
||||
this.removeTag = helper.removeTag.bind(helper);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user