@configura/web-utilities 2.3.0-alpha.0 → 2.3.0

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.
@@ -7,7 +7,16 @@ export declare class Observable<T> {
7
7
  stopListen: (listener: (v: T) => void) => void;
8
8
  stopAllListen: () => void;
9
9
  notifyAll: (v: T, context?: unknown) => void;
10
- link: (other: Observable<T>) => void;
10
+ /**
11
+ * Links the two observables so events raised in one will trigger the other one, and vice versa.
12
+ * @param other The other observable to link with
13
+ * @returns A function to unlink the two observables
14
+ */
15
+ link: (other: Observable<T>) => (() => void);
16
+ /**
17
+ * @deprecated This function does not unlink properly. Use the returned value from {@link link} instead.
18
+ * @param other The other observable to link with
19
+ */
11
20
  unlink: (other: Observable<T>) => void;
12
21
  }
13
22
  //# sourceMappingURL=Observable.d.ts.map
@@ -21,13 +21,27 @@ export class Observable {
21
21
  l.l(v);
22
22
  });
23
23
  };
24
+ /**
25
+ * Links the two observables so events raised in one will trigger the other one, and vice versa.
26
+ * @param other The other observable to link with
27
+ * @returns A function to unlink the two observables
28
+ */
24
29
  this.link = (other) => {
25
- this.listen((v) => other.notifyAll(v, this), other);
26
- other.listen((v) => this.notifyAll(v, other), this);
30
+ const thisListener = (v) => other.notifyAll(v, this);
31
+ const otherListener = (v) => other.notifyAll(v, other);
32
+ this.listen(thisListener, other);
33
+ other.listen(otherListener, this);
34
+ return () => {
35
+ this.stopListen(thisListener);
36
+ other.stopListen(otherListener);
37
+ };
27
38
  };
39
+ /**
40
+ * @deprecated This function does not unlink properly. Use the returned value from {@link link} instead.
41
+ * @param other The other observable to link with
42
+ */
28
43
  this.unlink = (other) => {
29
- this.stopListen(other.notifyAll);
30
- other.stopListen(this.notifyAll);
44
+ console.warn("The Observable.unlink() function has been deprecated. Use the returned value from link() instead");
31
45
  };
32
46
  }
33
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configura/web-utilities",
3
- "version": "2.3.0-alpha.0",
3
+ "version": "2.3.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,5 +22,5 @@
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
25
- "gitHead": "45b11d8e97c4f0c6e75cb3bb785005d238ffd046"
25
+ "gitHead": "243be1b5dec7980900b42ef82d4f74de682504ab"
26
26
  }