Description
Currently, the dispatchDataToStore()
method has a return type, which means the data attribute will have a return type.
A short example to allow for better explanation:
dispatchDataToStore(actions.example, this.apiService.someMethod<SomeDataType>(someValue), store, 'add');
Currently, the dispatchDataToStore
method will return SomeDataType
. (Reference)
This is done so that we can further work with the value set to the store, like for example:
dispatchDataToStore(actions.example, this.apiService.someMethod<SomeDataType>(someValue), store, 'add').pipe(map((value: SomeDataType) => value['someKey']));
The issue that arises, is that this voids the SSOT (Single Source Of Truth). If the latter example were to be wrapped in a method and called from a service, method, or component, it would be possible to assume that the value of example
in the store is of type typeof someKey
.
As a matter of principle, the dispatchDataToStore
should return void
or undefined
. This forces the user to switchMap
to the value in the store, which restores the SSOT principle.
This is a breaking change.