Create a gist now

Instantly share code, notes, and snippets.

@dbankier /Readme.md
Last active Dec 14, 2015

alloy.jmk for Alloy use with TiShadow

It enables you to free memory between launching TiShadow builds.

Updated based on @FokkeZB's improvements

task("post:compile", function(event,logger) {
var fs = require("fs"),
path = require("path");
if (event.alloyConfig.deployType === 'production') {
return;
}
var existing_bits = 'Alloy.createController("index");'
var tishadow_bits =
[ 'var index = Alloy.createController("index");',
'if (typeof exports !== "undefined") {',
' exports.close = function () {',
' index.getView().close();',
' };',
'}'
].join("\n");
var appjs = path.join(event.dir.resources, "app.js");
fs.writeFileSync(
appjs,
fs.readFileSync(appjs).toString().replace(existing_bits, tishadow_bits));
});
//Example app/controllers/index.js
$.index.addEventListener('close',function() {
// Add other cleanup bits hear if necessary
})
@FokkeZB

I've posted an improved version of the code at: http://fokkezb.nl/2013/05/22/tishadow-clean-up-for-alloy/

@dbankier
Owner

@FokkeZB, updated based on your improvements. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment