app/js/patchwork/core/Patch.js
/**
         * Removes a module from the patch.
         * @param moduleId
         */
Removes a module from the patch.
@param moduleId
Removes a module from the patch . @param moduleId
removeModuleById(moduleId) {
            let module = this.getModuleById(moduleId);
            if (module) {
                let moduleIndex = this.modules.indexOf(module);
                var connections = this.getConnectionsForModule(module);
                connections.forEach(connection => this.removeConnection(connection));
                this.modules.splice(moduleIndex, 1);
                if (module.definition.type === ModuleTypes_1.default.SUBPATCH) {
                    module.subPatch.clear();
                    this.removeEventListenersFromSubPatch(module.subPatch);
                    module.subPatch.destruct();
                }
                this.dispatchEvent(PatchEvent_1.default.MODULE_REMOVED, { module: module });
                this.removeEventListenersFromModule(module);
                module.destruct();
            }
            else {
                console.error('Module not found for id: ' + moduleId + ' (or not in list)');
            }
        }
removeModuleById ( moduleId ) { let module = this . getModuleById ( moduleId ) ; if ( module ) { let moduleIndex = this . modules . indexOf ( module ) ; var connections = this . getConnectionsForModule ( module ) ; connections . forEach ( connection => this . removeConnection ( connection ) ) ; this . modules . splice ( moduleIndex , 1 ) ; if ( module . definition . type === ModuleTypes_1 . default . SUBPATCH ) { module . subPatch . clear ( ) ; this . removeEventListenersFromSubPatch ( module . subPatch ) ; module . subPatch . destruct ( ) ; } this . dispatchEvent ( PatchEvent_1 . default . MODULE_REMOVED , { module : module } ) ; this . removeEventListenersFromModule ( module ) ; module . destruct ( ) ; } else { console . error ( 'Module not found for id: ' + moduleId + ' (or not in list)' ) ; } }
Removes a module from the patch.
Removes a module from the patch .
// first get all connections from or to this module // remove all these connections // remove module from list // and clear subpatch  // if subpatch, remove listeners // do this BEFORE destruct, so that listeners can still check the module's id todo maybe do it afterwards and pass the id? or do we need the full module // destruct