-
Notifications
You must be signed in to change notification settings - Fork 438
Expand file tree
/
Copy pathnonReactive.js
More file actions
26 lines (22 loc) · 980 Bytes
/
nonReactive.js
File metadata and controls
26 lines (22 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { LightningElement, api, track } from 'lwc';
import { Signal } from 'x/signal';
const signal = new Signal('initial value');
export default class extends LightningElement {
// Note that this signal is bound but it's never referenced on the template
_signal = signal;
@api apiSignalValue = signal.value;
@track trackSignalValue = signal.value;
observedFieldExternalSignalValue = signal.value;
// Note in the tests we use createElement outside of the LWC engine and therefore no template is
// actively rendering which is why this does not get automatically registered.
observedFieldBoundSignalValue = this._signal.value;
get externalSignalValueGetter() {
// Note that the value of the signal is not bound to the class and will therefore not be
// automatically subscribed to the re-render.
return signal.value;
}
@api
getSignalSubscriberCount() {
return signal.getSubscriberCount();
}
}