I have an angular app with @ngrx/component-store.
when the user selects an entry from a list of devices, I store this into component-store
component.ts:
onDeviceClicked(device: DeviceTO) {
this.inspectionStore.setDeviceSelected(device);
}
inspectionStore.ts
readonly setDeviceSelected = (data: DeviceTO) => {this.patchState({selectedDevice: data})};
Now, that the user has selected a device, a side effect should be triggered. However I am not sure how I can trigger a side effect when part of the state changed.
Do I need to do it when updating state?
readonly setDeviceSelected = (data: DeviceTO) => {
this.patchState({selectedDevice: data});
this.tiggerMySideEffect(data);
};
Or is there another way I can tell the sideEffect to listen for changes?