hooxs
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

hooxs

Effortlessly empower your project with typed hooks, enabling you to easily construct a plugin API for your needs. ✨

📦 Installation

npm install hooxs

📚 Usage

import { createHooks } from "hooxs";

interface RuntimeHooks {
  "build:before": () => void
  "build:after": (files: string[]) => void
  // can either be registered inside the hooks object or registered at a later point
  "config:load"?: (config: Record<string, unknown>) => void
}

const hooks = createHooks<RuntimeHooks>({
  "build:before": () => {
    console.log("before build");
  },
  "build:after": (files) => {
    console.log("after build", files);
  },
});
// or initialize hooks at a later point
const hooks = createHooks<RuntimeHooks>();

hooks.on("config:load", (config) => {
  console.log("config loaded", config);
});

await hooks.call("build:before");
const files = ["index.js", "index.css"];

await hooks.call("build:after", files);

📄 License

Published under MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i hooxs

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

8.98 kB

Total Files

7

Last publish

Collaborators

  • luxass