subscriptions: load on DOM ready

This commit is contained in:
Yoshua Wuyts
2016-06-20 15:11:28 +01:00
parent b6eb994357
commit bae31831fe
+5 -2
View File
@@ -81,15 +81,18 @@ 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
// be loaded
document.addEventListener('DOMContentLoaded', function () {
_models.forEach(function (model) { _models.forEach(function (model) {
if (model.subscriptions) { if (model.subscriptions) {
assert.ok(Array.isArray(model.subscriptions), 'subs must be an array') assert.ok(Array.isArray(model.subscriptions), 'subs must be an arr')
model.subscriptions.forEach(function (sub) { model.subscriptions.forEach(function (sub) {
sub(send) sub(send)
}) })
} }
}) })
})
// If an id is provided, the application will rehydrate // If an id is provided, the application will rehydrate
// on the node. If no id is provided it will return // on the node. If no id is provided it will return