Permalink
Browse files

A More Organized Plugin Structure: create a separate file for plugin …

…code
  • Loading branch information...
zschuessler committed Mar 16, 2017
1 parent df8ca42 commit 9649aac938bf92095b3ab51c540917d22336a558
@@ -1,3 +1,10 @@
@import 'app/SketchPlugin.cocoascript';
/**
* @type {SketchPlugin} The Sketch plugin app class.
*/
var plugin = new SketchPlugin();
/**
* onRun
*
@@ -7,5 +14,5 @@
* @param {object} context A generic object Sketch provides with information on the currently running Sketch instance.
*/
function onRun(context) {
context.document.displayMessage('Hello there!');
plugin.init(context);
}
@@ -0,0 +1,25 @@
/**
* SketchPlugin Class
*
* Manages CocoaScript code for our plugin.
*
* @constructor
*/
function SketchPlugin() {
// The Sketch context
this.context = {};
}
/**
* Init
*
* Sets the current app & plugin context, then renders the plugin.
*
* @param {object} sketchContext An object provided by Sketch with information on the currently running app and plugin.
* @returns {SketchPlugin}
*/
SketchPlugin.prototype.init = function(context) {
this.context = context;
return this;
}

0 comments on commit 9649aac

Please sign in to comment.