subscriptions: load on DOM ready

This commit is contained in:
Yoshua Wuyts
2016-06-20 15:11:28 +01:00
parent b6eb994357
commit bae31831fe
+11 -8
View File
@@ -81,14 +81,17 @@ function choo () {
// subscriptions are loaded after sendAction() is called // subscriptions are loaded after sendAction() is called
// because they both need access to send() and can't // because they both need access to send() and can't
// react to actions (read-only) // react to actions (read-only) - also wait on DOM to
_models.forEach(function (model) { // be loaded
if (model.subscriptions) { document.addEventListener('DOMContentLoaded', function () {
assert.ok(Array.isArray(model.subscriptions), 'subs must be an array') _models.forEach(function (model) {
model.subscriptions.forEach(function (sub) { if (model.subscriptions) {
sub(send) assert.ok(Array.isArray(model.subscriptions), 'subs must be an arr')
}) model.subscriptions.forEach(function (sub) {
} sub(send)
})
}
})
}) })
// If an id is provided, the application will rehydrate // If an id is provided, the application will rehydrate