Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/WebReflection/dom-augmentor
Same as augmentor but with DOM oriented useEffect handling via dropEffect.
https://github.com/WebReflection/dom-augmentor
Last synced: 3 months ago
JSON representation
Same as augmentor but with DOM oriented useEffect handling via dropEffect.
- Host: GitHub
- URL: https://github.com/WebReflection/dom-augmentor
- Owner: WebReflection
- License: isc
- Created: 2019-01-12T10:35:44.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-31T00:48:14.000Z (over 4 years ago)
- Last Synced: 2024-11-15T21:14:11.798Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 106 KB
- Stars: 59
- Watchers: 4
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dom-augmentor
[](https://travis-ci.com/WebReflection/dom-augmentor) [](https://coveralls.io/github/WebReflection/dom-augmentor?branch=master) [](https://greenkeeper.io/) 
**Social Media Photo by [stephan sorkin](https://unsplash.com/@sorkin) on [Unsplash](https://unsplash.com/)**
This is exactly the same as the [augmentor](https://github.com/WebReflection/augmentor) module, except it handles automatically effects per DOM nodes.
Compatible with any function that returns a DOM node, or a fragment, or a hyperhtml like Wire instance.
### Breaking in v1
* the default export has been removed, it's `import {augmentor} from 'augmentor'` now
* the `augmentor` library is the v1 one
* effects now work more reliably and there are no constrains for the guards### Example
**[Live Demo](https://codepen.io/WebReflection/pen/maQXwq)**
```js
const {augmentor: $, useEffect, useRef, useState} = augmentor;
const {render, hook} = lighterhtml;
const {html, svg} = hook(useRef);const Button = (text) => $(() => {
useEffect(
() => {
console.log('connected');
return () => console.log('disconnected');
},
[]
);
const [i, increment] = useState(0);
return html`
increment(i + 1)}>
${text} ${i}
`;
});const button = Button('hello');
render(document.body, button);
// alternatively
// document.body.appendChild(button());
```