Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

factory pattern with commonJS pattern to avoid 'new'

$
0
0

Hi,

I tried this in app.js:

! function() {
    var Obj = require('controls/test').createFoo();
    Obj.log();
}();
and in test.js:
var Foo = function() {
    return this;
};
Foo.prototype = {
    log : function() {
        console.log('test');
    }
};
exports.createFoo = function() {
    return new Foo();
};
It is a fork of this page. But it doesn't work in Titanium world. Any ideas?

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>