tbranyen/diffhtml

ReleaseHook for middleware

tbranyen opened this issue · 2 comments

A new middleware hook for when vTrees get released from calling release. I need a way to ensure consistent cleanup in the components testing repo.

It would work like the following:

const { innerHTML, use, release } = require('diffhtml');
const { assign } = Object;

use(assign(() => {}, {
  releaseHook(vTree) {
    // Do some additional cleanup with the VTree.
  }
}));

innerHTML(document.body, '<div />');
release(document.body);

This is something mostly used by tests? Seems straightforward enough. 👍

Yup! Basically I maintain caches in the diffhtml-components implementation that are separate from the core caches. I want to assert these are properly emptied on a per test basis.