Skip to content

Instantly share code, notes, and snippets.

@karantir
Last active January 16, 2017 20:45
Show Gist options
  • Save karantir/0a96336e6b1d82b5858f8657b4ddd808 to your computer and use it in GitHub Desktop.
Save karantir/0a96336e6b1d82b5858f8657b4ddd808 to your computer and use it in GitHub Desktop.
RactiveJS; RequireJS; Dynamic component; Condition based code loading
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