diff --git a/bootstrap.js b/bootstrap.js index 860539dc13c0c70b2569a70b952b31c415aef1a1..98626ea3f99c44f99835ba7d5e472a47a821a30d 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -18,7 +18,7 @@ import Manager from './hunks/manager.js' let NROL = new Manager() NROL.name = 'manager' NROL.id = 'NROL39_0' -NROL.init() +NROL.init() function bootloop() { NROL.loop() @@ -37,10 +37,14 @@ window.onload = () => { NROL.addLink(View.id, 'msgs', NROL.id, 'msgs') }).then(() => { NROL.addLink(NROL.id, 'msgs', View.id, 'msgs') - NROL.describeRunningProgram() + NROL.describeRunningProgram() bootloop() // and then we can load this program - NROL.addProgram('programs/linktest') + NROL.addProgram('programs/linktest').then((newHunks) => { + for (let hnk of newHunks) { + NROL.sendHunkAsDef(hnk) + } + }) }) } diff --git a/hunks/manager.js b/hunks/manager.js index 2b04fa082a6255ebc158fdaadbebb9216c48ab22..3fcdacd2f79c17f0d1c3f533319784f456b75517 100644 --- a/hunks/manager.js +++ b/hunks/manager.js @@ -421,14 +421,7 @@ function Manager() { reject('err in program load, at links', lnk) } } - // this manager should be having a program ? sub-programs ? - // an easy layer of heirarchy here ? - // TODO: what to do with names ? - resolve('gr8 success on program load') - // now we can notify listeners that we have new hunks - for (let hnk of newHunks) { - this.sendHunkAsDef(hnk) - } + resolve(newHunks) }) } else { reject(new Error('mysterious array handling inside of program load')) @@ -499,6 +492,14 @@ function Manager() { case 'listhunks': this.listHunksAvailable() break + case 'addprogram': + this.addProgram(content).then((newHunks) => { + // now we can notify listeners that we have new hunks + for (let hnk of newHunks) { + this.sendHunkAsDef(hnk) + } + }) + break case 'addhunk': console.log('MGR to add this hunk', content) this.addHunk(content).then((hunk) => {