atomicojs / atomico

Atomico a micro-library for creating webcomponents using only functions, hooks and virtual-dom.
https://atomicojs.dev
MIT License
1.16k stars 43 forks source link

1.10.0, New hook api and useLayoutEffect support #42

Closed UpperCod closed 3 years ago

UpperCod commented 3 years ago

New hook api

This change replaces the updated method with clearEffects, hoping with this change to give a better hook test experience, since it introduces a cleaning in stages, this cleaning in stages is designed to support the useLayoutEffect hook.

import { useLayoutEffect, useEffect } from "atomico";
import { createHooks } from "atomico/test-hooks";

const hooks = createHooks();

hooks.load(() => {
    useLayoutEffect(() => {
        console.log("first!");
    });
    useLayoutEffect(() => {
        console.log("last!");
    });
});

// run all useLayoutEffect
const clearLastEffect = hooks.clearEffects();

// run all useEffect
clearLastEffect();

useLayoutEffect

Improves the experience of associating DOM effects dependent on an asynchronous execution, this hook is ideal for computing styles to be processed later by useEffect

More tests