Closed webpro closed 10 years ago
As discussed at irc, here's is an out-of-the-box solution:
define('testModule/spec', {
testModule: {
create: {
module: 'testModule/main',
args: [{ $ref: 'viewNode' }]
},
destroy: 'remove'
},
detach: { compose: 'testModule.onDetach' },
attach: { compose: 'testModule.onAttach' }
});
Gonna close this one, if I have more questions I'll open another issue. Thanks @briancavalier!
Cool, glad that worked!
I have a controller that wires modules using
wire()
. Then I can also usewireContext.destroy()
to remove them later on.Now I would like to add lifecycle events, just like the
destroy
lifecycle/facet mechanism. Namely "detach" and "attach", e.g.:This way, things are nicely decoupled, and module authors are free to name the methods as they wish (just like for the
destroy
stage).What would be the best way to go about this?
I have been looking into the (plugin) docs, but I'm still not sure how to add this facet including the desired behavior (by creating a new plugin). Ideally, it's also possible to use e.g.
detach:before
as a facet.