You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Regular postal works great with require; if you publish on a channel from a dependency, the module depending on it receives that transmission through a subscription. I.E. if 'app/app' is defined like so:
define(['postal', 'postal.when'], function (postal) {
var app = postal;
return app;
});
Then, the following works:
requirejs(['app/app', 'app/homeBackgroundSlider'],
function ( app, homeBackgroundSlider) {
// homeBackgroundSlider sends homeBackgroundSlider.complete on the default channel
app.channel().subscribe('homeBackgroundSlider.complete', function() {
console.log('this works');
});
});
But this won't work:
requirejs(['app/app', 'app/homeBackgroundSlider'],
function ( app, homeBackgroundSlider) {
// homeBackgroundSlider sends homeBackgroundSlider.complete on the default channel
app.when([{topic: 'homeBackgroundSlider.complete'}], function() {
console.log('this doesn\'t work');
});
});
Now I've only started digging into postal.when, but my guess is that because 'app/homeBackgroundSlider' is included as a dependency, it actually executes before the module above, meaning that it publishes before the when statement listens. However, that it works using "vanilla" postal's subscribe means that perhaps this issue has to do with the postal.when code specifically. In fact, I had this issue elsewhere and created my own postal.when functionality in code, I just don't want to have to do that (makes postal.when useless in requireJS applications).
The text was updated successfully, but these errors were encountered:
Regular postal works great with require; if you publish on a channel from a dependency, the module depending on it receives that transmission through a subscription. I.E. if 'app/app' is defined like so:
Then, the following works:
But this won't work:
Now I've only started digging into postal.when, but my guess is that because 'app/homeBackgroundSlider' is included as a dependency, it actually executes before the module above, meaning that it publishes before the when statement listens. However, that it works using "vanilla" postal's subscribe means that perhaps this issue has to do with the postal.when code specifically. In fact, I had this issue elsewhere and created my own postal.when functionality in code, I just don't want to have to do that (makes postal.when useless in requireJS applications).
The text was updated successfully, but these errors were encountered: