larasopp 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/Core.d.ts CHANGED
@@ -7,6 +7,9 @@ export type TListenerCallback = (data: {
7
7
  channel: string;
8
8
  }) => void;
9
9
  export type TPermissions = 'public' | 'protected' | 'private';
10
+ export type TBind = {
11
+ remove: () => void;
12
+ };
10
13
  export type TMessage<T> = {
11
14
  subscribe?: string;
12
15
  unsubscribe?: string;
@@ -1,8 +1,5 @@
1
- import { TMessage, TListenerEvents, TListenerCallback } from "./Core";
1
+ import { TMessage, TListenerEvents, TListenerCallback, TBind } from "./Core";
2
2
  import { Event, Events } from "easy-event-emitter";
3
- type TReturn = {
4
- remove: () => void;
5
- };
6
3
  interface ISubscribe {
7
4
  events: Events;
8
5
  hasChannel: (channel: string) => boolean;
@@ -23,7 +20,7 @@ declare class Subscribe {
23
20
  constructor({ events, hasChannel, pushChannel, removeChannel, status, channel, send }: ISubscribe);
24
21
  get channel(): string;
25
22
  private init;
26
- bind<T>(event: string, callback: (data: T) => void): TReturn;
23
+ bind<T>(event: string, callback: (data: T) => void): TBind;
27
24
  remove(): void;
28
25
  addListener(event: TListenerEvents, callback: TListenerCallback): Event | undefined;
29
26
  }
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Event } from "easy-event-emitter";
2
- import Core, { IConfig, TPermissions, TSocketEvents, TListenerCallback } from "./Core";
2
+ import Core, { IConfig, TPermissions, TSocketEvents, TListenerCallback, TBind } from "./Core";
3
3
  import Subscribe from "./Subscribe";
4
4
  declare class Larasopp extends Core {
5
5
  private _channels;
@@ -12,5 +12,5 @@ declare class Larasopp extends Core {
12
12
  hasChannel(channel: string): boolean;
13
13
  addListener(event: TSocketEvents, callback: TListenerCallback): Event | undefined;
14
14
  }
15
- export type { Subscribe };
15
+ export type { Subscribe, TBind };
16
16
  export default Larasopp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "larasopp",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Websocket client for laravel",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/Core.ts CHANGED
@@ -12,6 +12,10 @@ export type TListenerCallback = (data:{channel: string}) => void;
12
12
 
13
13
  export type TPermissions = 'public' | 'protected' | 'private';
14
14
 
15
+ export type TBind = {
16
+ remove: () => void;
17
+ }
18
+
15
19
  export type TMessage<T> = {
16
20
  subscribe?: string;
17
21
  unsubscribe?: string;
package/src/Subscribe.ts CHANGED
@@ -2,16 +2,14 @@ import {
2
2
  TMessage,
3
3
  ListenerEvents,
4
4
  TListenerEvents,
5
- TListenerCallback
5
+ TListenerCallback,
6
+ TBind
6
7
  } from "./Core";
7
8
  import {
8
9
  Event,
9
10
  Events
10
11
  } from "easy-event-emitter";
11
12
 
12
- type TReturn = {
13
- remove: () => void;
14
- }
15
13
 
16
14
  interface ISubscribe {
17
15
  events: Events;
@@ -65,7 +63,7 @@ class Subscribe {
65
63
  }
66
64
  }
67
65
 
68
- public bind<T>(event: string, callback: (data: T) => void): TReturn {
66
+ public bind<T>(event: string, callback: (data: T) => void): TBind {
69
67
  const Event = this.events.addListener(this.channel + ':' + event, callback);
70
68
  return {
71
69
  remove: () => {
package/src/index.ts CHANGED
@@ -6,7 +6,8 @@ import Core,{
6
6
  TPermissions,
7
7
  SocketEvents,
8
8
  TSocketEvents,
9
- TListenerCallback
9
+ TListenerCallback,
10
+ TBind
10
11
  } from "./Core";
11
12
  import Subscribe from "./Subscribe";
12
13
 
@@ -76,7 +77,8 @@ class Larasopp extends Core {
76
77
  }
77
78
 
78
79
  export type {
79
- Subscribe
80
+ Subscribe,
81
+ TBind
80
82
  };
81
83
 
82
84
  export default Larasopp;