UNPKG

use-app-events

Version:

Event system for global communication in vanilla JavaScript and React.

71 lines (48 loc) • 1.96 kB
# use-app-events ![NPM Version](https://img.shields.io/npm/v/use-app-events?color=%2340bb12) ![NPM Unpacked Size](https://img.shields.io/npm/unpacked-size/use-app-events?color=%2340bb12) ![Code test coverage](https://img.shields.io/badge/coverage-100%25-40bb12?logo=100) ![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/use-app-events) Event system for global communication in vanilla JavaScript and React. šŸ“Ø Send events and data from one part of the app to another. šŸ“© Listen for events to occur in the app and process their payload. šŸŒ Organize and manage your global app state via events. <br/> ## Facts šŸ“¦ Small package size šŸƒ Tree-shakeable šŸ“ Well documented šŸ›”ļø Strictly typed with TypeScript ā™»ļø Works between different browser <u>tabs</u> āš›ļø Exports a convenient hook for <u>React</u> developers <br/> ## Install **npm** ```bash npm install use-app-events ``` **pnpm** ```bash pnpm add use-app-events ``` <br/> ## Exports - **notifyEventListeners** - Function to notify all listeners of the specified event type(s) subscribed via `listenForEvents`. - **listenForEvents** - Function to subscribe and listen for the specified event type(s) to occur in the app. - **listenForEvents.once** - Function to subscribe and listen for the specified event type(s) to occur in the app **once**. - **useAppEvents** - Hook for managing application events in React. - **heap** - _(readonly)_ Collection of resources operated by the package. - **options** - Collection of options used to adjust the behavior of the package. <br/> <br/> > _This is a truncated version of README to reduce the package size._ > > ##### [[_See full docs on GitHub_]](https://github.com/aimtbr/use-app-events?tab=readme-ov-file#use-app-events) <br/> ## License MIT ## Author Maksym Marchuk