From 3825631f07055143088c7f8ae8bae417c6a5916c Mon Sep 17 00:00:00 2001 From: Jake <jake.read@cba.mit.edu> Date: Sun, 24 Mar 2019 09:22:37 -0400 Subject: [PATCH] rm response from program load --- bootstrap.js | 10 +++++++--- hunks/manager.js | 17 +++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index 860539d..98626ea 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 2b04fa0..3fcdacd 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) => { -- GitLab