WebReflection / uland

A µhtml take at neverland
ISC License
108 stars 2 forks source link

Universal hooks support #13

Open loganvolkers opened 3 years ago

loganvolkers commented 3 years ago

Hey @WebReflection this is a bit of a call to action for unity.

At SaaSquatch we're using React and Stencil for building components using hooks for managing state. We created library for hooks called universal-hooks as a way of creating shareable hooks.

I'd love your feedback, and see if you have interest in collaborating to unify the hooks community across uland and neverland and haunted and others.

In particular, universal-hooks provides a haunted implementation of a testing library so that hooks can be cross-tested across hooks implementations.

WebReflection commented 3 years ago

I have hookedElements and uland, but also uce-template with hooks ... aaaaand heresy.

uland and hookedElements are the one that currently interest me the most though, but they are different from haunted, and I am not sure how to provide test cases ... the repo is not super clear in that regard, but also I don't understand what is a haunted implementation.

WebReflection commented 3 years ago

@loganvolkers any extra details you could share? if it wasn't clear, I'd like to help out/contribute as I can.

loganvolkers commented 3 years ago

Awesome, I just missed your response!

The thing that's needed is an implementation of the testing library. We have an interface defined in universal hooks testing library that hook consumers can write their tests against. React testing library and haunted testing library both implement the same interface.

The idea is you can write your hooks once and tests once, and then swap the implementations.

React testing library apparently has a reusable core that could be the foundation for the uhooks testing library, and we're the author's of haunted testing library.

I started looking at implementing a uhooks testing library, but didn't make it very far yet.

What's the easiest way to run the hooks in vanilla js from those libraries?

P.S. this is haunted: https://github.com/matthewp/haunted