Skip to content
Snippets Groups Projects
bootstrap.js 2.85 KiB
Newer Older
  • Learn to ignore specific revisions
  • Jake Read's avatar
    Jake Read committed
    // IDDE sends msgs to manager, does display etc 
    // starts with a native manager
    
    /* codename NROL39 aka cuttlefish */
    /* aka the teuthologist */
    
    // this is toplevel, UI is meta-hunk 
    // we run loop where UI passes messages to bower manager 
    // this is like the manager 'bootstrap' file ? 
    
    import Manager from './hunks/manager.js'
    
    // this is the TL
    // but heirarchichally, we can slave views to managers ... 
    // views push messages to managers ... 
    
    // our invisible overlord
    let NROL = new Manager()
    
    NROL.name = 'manager'
    
    Jake Read's avatar
    Jake Read committed
    NROL.id = 'NROL39_0'
    NROL.init() 
    
    function bootloop() {
        NROL.loop()
        setTimeout(bootloop)
    }
    
    
    // want handles on this we think ? 
    
    Jake Read's avatar
    Jake Read committed
    let View = {}
    
    
    window.onload = () => {
        console.log('BOOTUP')
    
    Jake Read's avatar
    Jake Read committed
        NROL.addHunk('hidden/view', 'TLView').then((view) => {
    
            View = view
            $('#wrapper').get(0).append(View.dom)
        }).then(() => {
            NROL.addLink(View.id, 'msgs', NROL.id, 'msgs')
        }).then(() => {
            NROL.addLink(NROL.id, 'msgs', View.id, 'msgs')
    
    Jake Read's avatar
    Jake Read committed
            NROL.describeRunningProgram() 
    
            // and then we can load this program
    
    Jake Read's avatar
    Jake Read committed
            NROL.addProgram('programs/linktest') 
    
    Jake Read's avatar
    Jake Read committed
    window.onload = () => {
    
    Jake Read's avatar
    Jake Read committed
        console.log('BOOOOOOOOOT')
    
    Jake Read's avatar
    Jake Read committed
        NROL.addHunk('manager').then((native) => {
            Native = native
            console.log('HELLO MANAGER', Native)
    
    Jake Read's avatar
    Jake Read committed
            NROL.addHunk('hidden/view').then((view) => {
                View = view
    
    Jake Read's avatar
    Jake Read committed
                console.log('HELLO VIEW', View)
    
    Jake Read's avatar
    Jake Read committed
                $('#wrapper').get(0).append(View.dom)
    
    Jake Read's avatar
    Jake Read committed
                try{
    
    Jake Read's avatar
    Jake Read committed
                    NROL.addLink(View.id, 'msgs', Native.id, 'msgs')
                    NROL.addLink(Native.id, 'msgs', View.id, 'msgs')
    
    Jake Read's avatar
    Jake Read committed
                } catch (err) {
                    console.log('no dice', err)
                }
    
    Jake Read's avatar
    Jake Read committed
                // NROL is hooked up, View is hooked to Native,
    
    Jake Read's avatar
    Jake Read committed
                // do startup program load 
                console.log("BEGIN THE PROGRAM LOADETH")
                Native.addProgram('programs/linktest').then((x) => {
                    console.log('PROGRAM LOADETH SUCCESS', x)
                    Native.describeRunningProgram()
                }).catch((err) => {
                    console.log('PROGRAM LOADETH NOT', err)
    
    Jake Read's avatar
    Jake Read committed
                })
                // let this happen in the context of the loop running?
                bootloop() 
                
    
    Jake Read's avatar
    Jake Read committed
                /*
    
    Jake Read's avatar
    Jake Read committed
                Native.addHunk('input/string').then((str) => {
                    Native.addHunk('interface/logger').then((lgr) => {
    
    Jake Read's avatar
    Jake Read committed
                        // connext
    
    Jake Read's avatar
    Jake Read committed
                        Native.addLinkByObject(str, 'string', lgr, 'tolog')
    
    Jake Read's avatar
    Jake Read committed
                        // needs 2 be buffered for multiple writes like this 
    
    Jake Read's avatar
    Jake Read committed
                        Native.sendHunkAsDef(str)
                        Native.sendHunkAsDef(lgr)
    
    Jake Read's avatar
    Jake Read committed
                        console.log('strang', str)
    
    Jake Read's avatar
    Jake Read committed
                        console.log('logger', lgr)
                    })
                })
    
    Jake Read's avatar
    Jake Read committed
                console.log('BOOOOOOOOOT BEGIN')
    
    Jake Read's avatar
    Jake Read committed
                bootloop()
    
    Jake Read's avatar
    Jake Read committed
            })
        })