Last active
December 17, 2015 18:59
-
-
Save marcobarbosa/5656808 to your computer and use it in GitHub Desktop.
Flight delegation
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( | |
[ | |
'flight/component' | |
], | |
function (defineComponent) { | |
return defineComponent(helloWorld); | |
function helloWorld() { | |
this.injectFooBar = function() { | |
// Silly example but here I inject | |
// an element that interests foobar. | |
// But since it's done after initialization | |
// foobar won't catch it. | |
var $newElement = "<div class=\"foobar\"></div>"; | |
this.$node.append( $newElement ); | |
// Could I maybe: | |
// fooBarUI.attachTo($newElement) - or something? | |
} | |
} | |
} | |
); | |
define( | |
[ | |
'flight/component' | |
], | |
function (defineComponent) { | |
return defineComponent(fooBar); | |
function fooBar() { | |
this.doStuff = function() { | |
// ... | |
} | |
this.after('initilize'injectFooBar = function() { | |
// add listeners on nodes inside .foobar | |
} | |
} | |
} | |
); | |
define( | |
[ | |
'ui/foobar', | |
'ui/helloworld' | |
], | |
function( | |
fooBarUI, | |
helloWorldUI) { | |
var initialize = function() { | |
foobar.attachTo('.foobar'); | |
helloWorld.attachTo('#hello-world'); | |
} | |
return { | |
initialize: initialize | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment