Last active
January 16, 2017 20:45
-
-
Save karantir/0a96336e6b1d82b5858f8657b4ddd808 to your computer and use it in GitHub Desktop.
RactiveJS; RequireJS; Dynamic component; Condition based code loading
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
'ractive', | |
'module'], | |
function(Ractive, module) { | |
return Ractive.extend({ | |
template: '{{# isLoaded }}<innerComponent />{{/ isLoaded }}', | |
components: { | |
innerComponent: function() { | |
return getInnerComponentName(this); | |
} | |
}, | |
oninit: function() { | |
var self = this; | |
require([getInnerComponentPath(this, module)], function(innerComponent) { | |
self.set('isLoaded', true); | |
}); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment