Skip to content

Commit

Permalink
📦 - Package release 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
svnrnns committed Aug 11, 2024
1 parent ae28f19 commit 970263d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ const MyComponent = () => {
export default MyComponent;
```

### eventEmit (function)
### useEventEmit (function)

The `eventEmit` function allows you to emit custom events.
The `useEventEmit` function allows you to emit custom events.

```jsx
import React from 'react';
import { eventEmit } from 'mitt-react';
import { useEventEmit } from 'mitt-react';

const MyEmitterComponent = () => {
const handleClick = () => {
eventEmit('customEvent', 'Hello, World!');
useEventEmit('customEvent', 'Hello, World!');
};

return <button onClick={handleClick}>Emit Event</button>;
Expand All @@ -67,7 +67,7 @@ A hook to listen for a custom event.
| eventName | string | &cross; | The name of the event to listen for |
| handler | Function | &cross; | The function to call when the event is emitted. |

### eventEmit
### useEventEmit

A function to emit a custom event.

Expand Down
24 changes: 13 additions & 11 deletions dist/mitt-react.es.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback as c, useEffect as u } from "react";
function r(t) {
import { useCallback as f, useEffect as u } from "react";
function s(t) {
return { all: t = t || /* @__PURE__ */ new Map(), on: function(i, e) {
var n = t.get(i);
n ? n.push(e) : t.set(i, [e]);
Expand All @@ -15,17 +15,19 @@ function r(t) {
});
} };
}
const f = r();
function m(t, i) {
const e = c(i, [i]);
u(() => (f.on(t, e), () => {
f.off(t, e);
}), [t, e]);
const c = s();
function r(t, i) {
c.emit(t, i);
}
function a(t, i) {
f.emit(t, i);
const e = f(i, [i]);
u(() => (c.on(t, e), () => {
c.off(t, e);
}), [t, e]);
}
const l = r;
export {
a as eventEmit,
m as useEventListener
l as eventEmit,
r as useEventEmit,
a as useEventListener
};
2 changes: 1 addition & 1 deletion dist/mitt-react.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mitt-react",
"private": false,
"version": "1.0.0",
"version": "1.1.0",
"description": "Lightweight utility for integrating mitt with React",
"license": "MIT",
"type": "module",
Expand Down

0 comments on commit 970263d

Please sign in to comment.