@lincode/events 1.0.27 → 1.0.28
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/event.d.ts +13 -4
- package/lib/event.js +1 -1
- package/lib-commonjs/event.js +2 -0
- package/package.json +4 -5
- package/src/event.ts +1 -1
package/lib/event.d.ts
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
import { Cancellable } from "@lincode/promiselikes";
|
2
|
-
declare
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
export declare class Event<Payload = void> {
|
3
|
+
private cbs;
|
4
|
+
private state?;
|
5
|
+
on(cb: (val: Payload) => void): Cancellable;
|
6
|
+
once(cb: (val: Payload) => void): Cancellable;
|
7
|
+
emit(value: Payload): void;
|
8
|
+
setState(value: Payload): void;
|
9
|
+
getState(): Payload | undefined;
|
10
|
+
}
|
11
|
+
type Emit<T> = (val: T, isState?: boolean) => void;
|
12
|
+
type On<T> = (cb: (val: T) => void, once?: boolean) => Cancellable;
|
13
|
+
type GetState<T> = () => T | undefined;
|
14
|
+
export type EventFunctions = readonly [
|
6
15
|
Emit<void>,
|
7
16
|
On<void>,
|
8
17
|
Emit<void>,
|
package/lib/event.js
CHANGED
package/lib-commonjs/event.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Event = void 0;
|
3
4
|
const promiselikes_1 = require("@lincode/promiselikes");
|
4
5
|
class Event {
|
5
6
|
constructor() {
|
@@ -33,6 +34,7 @@ class Event {
|
|
33
34
|
return this.state;
|
34
35
|
}
|
35
36
|
}
|
37
|
+
exports.Event = Event;
|
36
38
|
exports.default = () => {
|
37
39
|
const event = new Event();
|
38
40
|
const emit = (val) => event.emit(val);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lincode/events",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.28",
|
4
4
|
"description": "Generated by ambients-cli",
|
5
5
|
"author": "Lai Schwe",
|
6
6
|
"license": "MIT",
|
@@ -8,12 +8,11 @@
|
|
8
8
|
"ambients"
|
9
9
|
],
|
10
10
|
"dependencies": {
|
11
|
-
"@lincode/promiselikes": "
|
12
|
-
"@lincode/utils": "
|
11
|
+
"@lincode/promiselikes": "^1.0.24",
|
12
|
+
"@lincode/utils": "^1.3.5"
|
13
13
|
},
|
14
|
-
"peerDependencies": {},
|
15
14
|
"devDependencies": {
|
16
|
-
"typescript": "
|
15
|
+
"typescript": "^4.9.4"
|
17
16
|
},
|
18
17
|
"scripts": {
|
19
18
|
"build": "ambients clean && yarn tsc && yarn tsc -p tsconfig-commonjs.json",
|