An open API service indexing awesome lists of open source software.

https://github.com/codewell/on-event

Trigger function on event and pass the event as argument to the function
https://github.com/codewell/on-event

Last synced: 6 days ago
JSON representation

Trigger function on event and pass the event as argument to the function

Awesome Lists containing this project

README

          

# @codewell/on-event

Wrapper function that passes JavaScript event as first parameter to a function when the event is triggered.

```JavaScript
const onEvent = (func, ...args) => (event) => func(event, ...args);
```

## Installation

```
npm install @codewell/on-event
```

## Basic Usage

```JavaScript
import onEvent from '@codewell/on-event';

const handleClickEvent = (event) => {
// Handle the click event...
};

const SomeComponent = (props) => (

);

```

```JavaScript
import onEvent from '@codewell/on-event';

const handleInputChange = (event, label) => {
const inputValue = event.target.value;
return `${label}: ${inputValue}`;
// "first name: some input value..."
}

const SomeComponent = (props) => (

)

```