-
Notifications
You must be signed in to change notification settings - Fork 22
Description
I want to introduce fine-grained reactivity to the HTML report.
Current situation
In the current situation, real-time updates are implemented ad hoc. This means that metrics
are used to calculate the model. Subsequent updates result in recalculating the whole model. Code is rendered and drawn on the screen. To get acceptable performance, changes that are streaming in are buffered. I think this makes it unusable for big code files (like the one found in the TypeScript project).
Suggested improvement.
I want to create a small signals library right into the metrics
package. This would allow devs to update the status of a mutant, resulting in cascading changes in the entire model (so file metrics and parent directory metrics). Next, we could wire up these signals into the "reactive" base class we are currently using, drawing inspirations from @lit-labs/preact-signals
.
The result is that changes to the model automatically cascade to the screen, no need for the custom update code we use now.
I want to implement this as a breaking change to keep things simpler.
Alternatives I've considered
- We could create a custom solution inside
metrics
like this, and keep the rest of the API the same:However, more is needed to solve the more significant issue of what to update on the screen.const report = new MutationTestingReport(reportsJson); // report.results etc work as they do now. report.updateMutant(mutant); // report.results etc updated
- We could try to depend on
@lit-labs/preact-signals
directly frommetrics
and use that library. However, this would add a dependency tometrics
, which also adds that dependency to all dependents, like the dashboard and StrykerJS. Also, if lit-labs ever decided on a different Signals API, it would mean further breaking changes. As stated in their blog, they landed on preact-signals with little consideration.