@lincode/events 1.0.26 → 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 CHANGED
@@ -1,6 +1,21 @@
1
1
  import { Cancellable } from "@lincode/promiselikes";
2
- export declare type Emit<T> = (val: T, isState?: boolean) => void;
3
- export declare type On<T> = (cb: (val: T) => void, once?: boolean) => Cancellable;
4
- export declare type GetState<T> = () => T | undefined;
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 [
15
+ Emit<void>,
16
+ On<void>,
17
+ Emit<void>,
18
+ GetState<void>
19
+ ];
5
20
  declare const _default: <T = void>() => readonly [Emit<T>, On<T>, Emit<T>, GetState<T>];
6
21
  export default _default;
package/lib/event.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Cancellable } from "@lincode/promiselikes";
2
- class Event {
2
+ export class Event {
3
3
  constructor() {
4
4
  this.cbs = new Set();
5
5
  }
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { default, default as Events } from "./Events";
2
- export { default as event, Emit, On, GetState } from "./event";
2
+ export { default as event, EventFunctions } from "./event";
@@ -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.26",
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",
package/src/event.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Cancellable } from "@lincode/promiselikes"
2
2
 
3
- class Event<Payload = void> {
3
+ export class Event<Payload = void> {
4
4
  private cbs = new Set<(val: Payload) => void>()
5
5
  private state?: Payload
6
6
 
@@ -37,9 +37,16 @@ class Event<Payload = void> {
37
37
  }
38
38
  }
39
39
 
40
- export type Emit<T> = (val: T, isState?: boolean) => void
41
- export type On<T> = (cb: (val: T) => void, once?: boolean) => Cancellable
42
- export type GetState<T> = () => T | undefined
40
+ type Emit<T> = (val: T, isState?: boolean) => void
41
+ type On<T> = (cb: (val: T) => void, once?: boolean) => Cancellable
42
+ type GetState<T> = () => T | undefined
43
+
44
+ export type EventFunctions = readonly [
45
+ Emit<void>,
46
+ On<void>,
47
+ Emit<void>,
48
+ GetState<void>
49
+ ]
43
50
 
44
51
  export default <T = void>() => {
45
52
  const event = new Event<T>()
package/src/index.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { default, default as Events } from "./Events"
2
- export { default as event, Emit, On, GetState } from "./event"
2
+ export { default as event, EventFunctions } from "./event"