From eeaff42e16daaf8089fd857e3b26b53fe2ce2928 Mon Sep 17 00:00:00 2001 From: Timothy Farrell Date: Sun, 17 Dec 2017 21:52:52 -0600 Subject: [PATCH] Lazyify iterating subscriptions array un subscribeToRender This allows the array to be manipulated between subscribeToRender call and view unmounting. --- packages/gallery/src/utils/domvm.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/gallery/src/utils/domvm.js b/packages/gallery/src/utils/domvm.js index a38e73b..8932d35 100644 --- a/packages/gallery/src/utils/domvm.js +++ b/packages/gallery/src/utils/domvm.js @@ -6,9 +6,13 @@ import { error } from '../services/console.js'; export function subscribeToRender(vm, subscribables, subscriptions) { const redraw = (...args) => vm.redraw(); - const subList = subscribables.map(s => s.subscribe(redraw)).concat(subscriptions); + const subList = subscribables.map(s => s.subscribe(redraw)); - vm.config({ hooks: { willUnmount: () => subList.forEach(call) } }); + vm.config({ + hooks: { + willUnmount: () => subList.concat(subscriptions).forEach(call) + } + }); } export function patchRefStyle(ref, style, evt, node, vm) {