update tsconfig
This commit is contained in:
parent
11f60dc2f5
commit
b175669135
@ -12,10 +12,19 @@
|
||||
"gitrepo": "smartevent",
|
||||
"shortDescription": "handle events in smart ways",
|
||||
"npmPackagename": "@push.rocks/smartevent",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"description": "A library to handle events in smart ways, integrating features to work with promises.",
|
||||
"keywords": [
|
||||
"event handling",
|
||||
"smart event management",
|
||||
"typescript",
|
||||
"promises integration",
|
||||
"asynchronous programming",
|
||||
"event-driven development"
|
||||
]
|
||||
}
|
||||
},
|
||||
"tsdocs": {
|
||||
"tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||
}
|
||||
}
|
10
package.json
10
package.json
@ -2,7 +2,7 @@
|
||||
"name": "@push.rocks/smartevent",
|
||||
"version": "2.0.5",
|
||||
"private": false,
|
||||
"description": "handle events in smart ways",
|
||||
"description": "A library to handle events in smart ways, integrating features to work with promises.",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
@ -43,5 +43,13 @@
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"keywords": [
|
||||
"event handling",
|
||||
"smart event management",
|
||||
"typescript",
|
||||
"promises integration",
|
||||
"asynchronous programming",
|
||||
"event-driven development"
|
||||
]
|
||||
}
|
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
113
readme.md
113
readme.md
@ -1,32 +1,103 @@
|
||||
# @pushrocks/smartevent
|
||||
# @push.rocks/smartevent
|
||||
handle events in smart ways
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartevent)
|
||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartevent)
|
||||
* [github.com (source mirror)](https://github.com/pushrocks/smartevent)
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartevent/)
|
||||
## Install
|
||||
To install @push.rocks/smartevent for use in your project, run the following command in your project root:
|
||||
|
||||
## Status for master
|
||||
[![pipeline status](https://gitlab.com/pushrocks/smartevent/badges/master/pipeline.svg)](https://gitlab.com/pushrocks/smartevent/commits/master)
|
||||
[![coverage report](https://gitlab.com/pushrocks/smartevent/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartevent/commits/master)
|
||||
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartevent.svg)](https://www.npmjs.com/package/@pushrocks/smartevent)
|
||||
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartevent/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartevent)
|
||||
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
|
||||
```bash
|
||||
npm install @push.rocks/smartevent --save
|
||||
```
|
||||
|
||||
This command will add `@push.rocks/smartevent` to your project's dependencies, ensuring that its functionality is available for import and use within your application.
|
||||
|
||||
## Usage
|
||||
|
||||
Use intellisense for best in class intellisense.
|
||||
The `@push.rocks/smartevent` package provides an enhanced event handling mechanism on top of the native Node.js `EventEmitter`. It leverages TypeScript and modern JavaScript features to smartly handle events within your application.
|
||||
|
||||
## Contribution
|
||||
### Importing the Module
|
||||
Begin by importing the necessary classes and functions from the module. This can be done as follows:
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
```typescript
|
||||
import { SmartEventEmitter, once } from '@push.rocks/smartevent';
|
||||
```
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
### Using `SmartEventEmitter`
|
||||
The `SmartEventEmitter` class is an extension of the native `EventEmitter` provided by Node.js but with additional capabilities. Let's see how to use it.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
#### Creating an Instance
|
||||
|
||||
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
|
||||
```typescript
|
||||
const mySmartEventEmitter = new SmartEventEmitter();
|
||||
```
|
||||
|
||||
#### Emitting Events
|
||||
With an instance of `SmartEventEmitter`, emitting events is straightforward. You simply use the `emit` method.
|
||||
|
||||
```typescript
|
||||
mySmartEventEmitter.emit('myCustomEvent', { key: 'value' });
|
||||
```
|
||||
|
||||
#### Listening for Events
|
||||
To listen for events, use the `on` method, passing the event name and a callback function that will be executed when the event is emitted.
|
||||
|
||||
```typescript
|
||||
mySmartEventEmitter.on('myCustomEvent', (data) => {
|
||||
console.log('Event data:', data);
|
||||
});
|
||||
```
|
||||
|
||||
#### Listening for an Event Once
|
||||
You might want to listen for an event only once and then automatically remove the listener. This can be achieved with the `once` method.
|
||||
|
||||
```typescript
|
||||
mySmartEventEmitter.once('myCustomEvent', (data) => {
|
||||
console.log('This will be logged only once:', data);
|
||||
});
|
||||
```
|
||||
|
||||
### Using `once` Async Function
|
||||
The `once` function provides a way to wait for an event to occur exactly once before proceeding. It returns a promise that resolves when the specified event is emitted.
|
||||
|
||||
```typescript
|
||||
(async () => {
|
||||
const eventData = await once<string>(mySmartEventEmitter, 'myCustomEvent');
|
||||
console.log('Event data received asynchronously:', eventData);
|
||||
})();
|
||||
```
|
||||
|
||||
This functionality is particularly useful when dealing with asynchronous operations that trigger events on completion.
|
||||
|
||||
### Advanced Use Cases
|
||||
The simplicity and power of `@push.rocks/smartevent` enable a variety of advanced use cases, such as coordinating complex event-driven flows, or integrating with other promise-based or async/await code seamlessly.
|
||||
|
||||
Given its reliance on TypeScript, developers can benefit from strong typing, which adds to code robustness and maintainability. When defining event payloads, consider specifying interfaces or types for the data objects being passed around to ensure type safety across your event listeners.
|
||||
|
||||
For those working in environments that support Observables, `@push.rocks/smartevent` can interoperate with libraries like RxJS, allowing events to be transformed into Observable streams for more complex event handling strategies.
|
||||
|
||||
### Final Thoughts
|
||||
`@push.rocks/smartevent` is a utilities suite that extends the native event handling capabilities provided by Node.js, giving developers a smarter way to manage events within their applications. Its integration with TypeScript enhances developer experience through better tooling support and type safety. Whether you're building a small utility library or a large-scale application, `@push.rocks/smartevent` provides a solid foundation for your event management needs.
|
||||
|
||||
Remember, the most effective way to use `@push.rocks/smartevent` is by thoroughly understanding the events in your application and how they interact with various components. With smart events, you can design a more reactive, maintainable, and scalable application architecture.
|
||||
|
||||
For further exploration, the module includes types and interfaces that encourage best practices for event-driven programming in TypeScript, ensuring that you get the most out of your event handling logic.
|
||||
|
||||
By integrating `@push.rocks/smartevent` into your project, you empower yourself with a flexible and powerful tool for managing events, which is essential for building responsive and interactive Node.js applications.
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
|
||||
### Trademarks
|
||||
|
||||
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||
|
Loading…
Reference in New Issue
Block a user