@happy-gastro/global-observables

1.5.0 • Public • Published

@happy-gastro/global-observables

@happy-gastro/global-observables is a module for managing observable events globally in your application. It provides methods for registering, calling, and removing observable events, allowing different parts of your application to communicate and respond to events.

Installation

You can install @happy-gastro/global-observables via npm:

npm install @happy-gastro/global-observables

Usage

To use this package, import the generateCSRAndKey function and call it with optional parameters:

// Import the Observables module
import Observables from "@happy-gastro/global-observables"

// Register an observable event
Observables.register('eventName', (data) => {
    console.log(`Received event 'eventName' with data: ${data}`);
});

// Call the registered observable event
Observables.call('eventName', { someData: 'value' });

// Remove the registered observable event
Observables.remove('eventName');

Example

// Import the Observables module
import Observables from "@happy-gastro/global-observables"

// Register an observable event
Observables.register('showAlertWindow', (data) => {
    console.log(`Received event 'showAlertWindow' with data: ${data}`);
    alert("Received event:" + data.text)
});

// Call the registered observable event
Observables.call('showAlertWindow', { text: 'Test alert content!' });

// Remove the registered observable event
Observables.remove('showAlertWindow');

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Author

This project is developed and maintained by Farkas Ferenc.

Company

Happy Gastro Ltd.

License

MIT

Package Sidebar

Install

npm i @happy-gastro/global-observables

Weekly Downloads

2

Version

1.5.0

License

ISC

Unpacked Size

6.97 kB

Total Files

7

Last publish

Collaborators

  • fbalazs
  • fecnysmith