logger = (returnFn, renderFn) => {
const dispatch = d3.dispatch("fn");
const history = [];
const observer = Generators.observe(next => {
next(null);
dispatch.on("fn", function(...args) {
history.unshift(renderFn(...args));
if (history.length > 9) history.pop();
next(
html`<div style="display: flex; flex-wrap: wrap;">${history.map(
d => html`${d}`
)}</div>`
);
});
return () => dispatch.on("fn", null);
});
const log = function(...args) {
dispatch.call("fn", null, ...args);
return returnFn(...args);
};
return Object.assign(log, { observer });
}