From e0b11276ebd2d28581f85114e40d8d59590b84ca Mon Sep 17 00:00:00 2001 From: abe33 Date: Thu, 17 Dec 2015 12:42:11 +0100 Subject: [PATCH] :racehorse: Lazy load model and views Closes #430 --- lib/main.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index d3851e38..88269138 100644 --- a/lib/main.js +++ b/lib/main.js @@ -12,10 +12,9 @@ Object.keys(require.cache).filter((p) => { import {Emitter, CompositeDisposable} from 'atom' import include from './decorators/include' -import Minimap from './minimap' -import MinimapElement from './minimap-element' import PluginManagement from './mixins/plugin-management' -import MinimapPluginGeneratorElement from './minimap-plugin-generator-element' + +let Minimap, MinimapElement, MinimapPluginGeneratorElement /** * The `Minimap` package provides an eagle-eye view of text buffers. @@ -91,6 +90,9 @@ class Main { activate () { if (this.active) { return } + if (!Minimap) { Minimap = require('./minimap') } + if (!MinimapElement) { MinimapElement = require('./minimap-element') } + MinimapElement.registerViewProvider(Minimap) this.subscriptionsOfCommands = atom.commands.add('atom-workspace', { @@ -167,6 +169,9 @@ class Main { * @param {string} template the name of the template to use */ generatePlugin (template) { + if (!MinimapPluginGeneratorElement) { + MinimapPluginGeneratorElement = require('./minimap-plugin-generator-element') + } var view = new MinimapPluginGeneratorElement() view.template = template view.attach()