From f8caddaf645d0680b1ef4b0891c6d48b236e679f Mon Sep 17 00:00:00 2001 From: Timothy Farrell Date: Tue, 11 Sep 2018 15:18:19 -0500 Subject: [PATCH] Upgrade domvm to 3.4.5 --- packages/gallery/package.json | 2 +- packages/gallery/src/utils/event.js | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/gallery/package.json b/packages/gallery/package.json index 759956e..7bdbd8f 100644 --- a/packages/gallery/package.json +++ b/packages/gallery/package.json @@ -15,7 +15,7 @@ "backgroundtask": "~1.0.0", "body-parser": "~1.18.3", "date-fns": "~1.29.0", - "domvm": "~3.2.1", + "domvm": "~3.4.5", "exif-parser": "~0.1.9", "express": "~4.16.3", "frptools": "~3.2.0", diff --git a/packages/gallery/src/utils/event.js b/packages/gallery/src/utils/event.js index addb245..bbe816d 100644 --- a/packages/gallery/src/utils/event.js +++ b/packages/gallery/src/utils/event.js @@ -1,8 +1,18 @@ -import { log, group, groupEnd } from '../utils/console.js'; +import { call } from 'frptools'; export const streamConfig = { is: s => s && typeof s.subscribe === 'function', - val: s => s(), sub: (s, fn) => s.subscribe(fn), - unsub: s => s() + off: subList => subList.forEach(call), + on: (accum, vm) => { + const redraw = () => vm.redraw(); + return accum.map(s => (streamConfig.is(s) ? streamConfig.sub(s, redraw) : s())); + }, + val: (s, accum) =>{ + if (streamConfig.is(s)) { + accum.push(s); + return s(); + } + return s; + } };