@placeos/ts-client 4.2.0 → 4.2.2
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/README.md +2 -2
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +538 -521
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/realtime/module.d.ts +6 -0
- package/dist/realtime/status-variable.d.ts +3 -1
- package/package.json +1 -1
- package/src/realtime/module.ts +12 -0
- package/src/realtime/status-variable.ts +11 -1
|
@@ -16,8 +16,14 @@ export declare class PlaceModuleBinding {
|
|
|
16
16
|
/**
|
|
17
17
|
* Get binding with the given name
|
|
18
18
|
* @param name Name of the binding
|
|
19
|
+
* @deprecated Use `variable` instead
|
|
19
20
|
*/
|
|
20
21
|
binding<T = any>(name: string): PlaceVariableBinding<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Get binding with the given name
|
|
24
|
+
* @param name Name of the binding
|
|
25
|
+
*/
|
|
26
|
+
variable<T = any>(name: string): PlaceVariableBinding<T>;
|
|
21
27
|
/**
|
|
22
28
|
* Execute method on the engine module
|
|
23
29
|
* @param method Name of the method
|
|
@@ -20,10 +20,12 @@ export declare class PlaceVariableBinding<T = any> {
|
|
|
20
20
|
*/
|
|
21
21
|
listen(): Observable<T>;
|
|
22
22
|
/**
|
|
23
|
-
* Subscribe to changes of the variable's binding value
|
|
23
|
+
* Subscribe to changes of the variable's binding value.
|
|
24
|
+
* Note: Initial value emitted may be `undefined`
|
|
24
25
|
* @param next Callback for changes to the bindings value
|
|
25
26
|
*/
|
|
26
27
|
subscribe(next: (value: T) => void): Subscription;
|
|
28
|
+
bindThenSubscribe(next: (value: T) => void): Subscription;
|
|
27
29
|
/**
|
|
28
30
|
* Bind to the status variable's value
|
|
29
31
|
*/
|
package/package.json
CHANGED
package/src/realtime/module.ts
CHANGED
|
@@ -38,6 +38,7 @@ export class PlaceModuleBinding {
|
|
|
38
38
|
/**
|
|
39
39
|
* Get binding with the given name
|
|
40
40
|
* @param name Name of the binding
|
|
41
|
+
* @deprecated Use `variable` instead
|
|
41
42
|
*/
|
|
42
43
|
public binding<T = any>(name: string) {
|
|
43
44
|
if (!this._bindings[name]) {
|
|
@@ -46,6 +47,17 @@ export class PlaceModuleBinding {
|
|
|
46
47
|
return this._bindings[name] as PlaceVariableBinding<T>;
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Get binding with the given name
|
|
52
|
+
* @param name Name of the binding
|
|
53
|
+
*/
|
|
54
|
+
public variable<T = any>(name: string) {
|
|
55
|
+
if (!this._bindings[name]) {
|
|
56
|
+
this._bindings[name] = new PlaceVariableBinding<T>(this, name);
|
|
57
|
+
}
|
|
58
|
+
return this._bindings[name] as PlaceVariableBinding<T>;
|
|
59
|
+
}
|
|
60
|
+
|
|
49
61
|
/**
|
|
50
62
|
* Execute method on the engine module
|
|
51
63
|
* @param method Name of the method
|
|
@@ -72,13 +72,23 @@ export class PlaceVariableBinding<T = any> {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
* Subscribe to changes of the variable's binding value
|
|
75
|
+
* Subscribe to changes of the variable's binding value.
|
|
76
|
+
* Note: Initial value emitted may be `undefined`
|
|
76
77
|
* @param next Callback for changes to the bindings value
|
|
77
78
|
*/
|
|
78
79
|
public subscribe(next: (value: T) => void): Subscription {
|
|
79
80
|
return this.listen().subscribe(next);
|
|
80
81
|
}
|
|
81
82
|
|
|
83
|
+
public bindThenSubscribe(next: (value: T) => void): Subscription {
|
|
84
|
+
const unbind = this.bind();
|
|
85
|
+
return this.listen().subscribe({
|
|
86
|
+
next,
|
|
87
|
+
complete: () => unbind(),
|
|
88
|
+
error: () => unbind(),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
82
92
|
/**
|
|
83
93
|
* Bind to the status variable's value
|
|
84
94
|
*/
|