call-func
v0.4.0
Published
call function
Downloads
2,579
Maintainers
Readme
Call Function
- GIT
- https://github.com/react-atomic/react-atomic-organism/tree/main/packages/lib/call-func
- NPM
- https://www.npmjs.com/package/call-func
Event addEventListener wrapper
subscribe
HTML
<button>Click</button>
JS
import { register, cleanAllRegister } from "call-func";
const oReg = register(document.querySelector("button"));
const regId = oReg.addEventListener("click", () => {
console.log("click");
});
unsubscribe
by id
// clean one
oReg.removeEventListener(regId);
// clean one dom events by type.
oReg.cleanAll("click");
// clean one dom all events.
oReg.cleanAll();
// clean events which regist by this library.
cleanAllRegister();