@kqraze/vue
v2.2.9
Published
A lightweight Vue 3 library for managing API requests with caching, state management, reactivity, and event hooks.
Readme
@kqraze/vue
⚡ A set of functions, methods, and hooks for Vue 3 written with strict TypeScript typing.
💎 Installation
To install the library, use the following command:
npm install -D @kqraze/vue✅ Active Functions List
🔹 useApi()
A composable for handling API requests with caching, state management, and data adaptation.
🔹 createEventHook()
A utility for managing events, allowing you to subscribe, unsubscribe, and trigger handlers.
🔹 useAwaitingEvent()
A composable utility for managing delayed execution with a waiting state. It allows you to execute an event with a specified timeout, track its progress, cancel it, and dynamically update the timeout.
🔹 deepClone()
A utility to clone a JSON Like object and get rid of the reference (the same as the same asJSON.parse(JSON.stringify(data)))
🎯 Usage
Here's an example of how to use createEventHook():
import { createEventHook } from '@kqraze/vue'
const messageHook = createEventHook<string>();
// Subscribe to the event
messageHook.on((message) => {
console.log("Message received:", message);
});
// Trigger the event
messageHook.trigger("Hello world!"); // The console will display: Message received: Hello world!