StoreWritable.on() reports `undefined` returned from reducer
- Dominant language
- TypeScript
- Stars
- 4.9k
- Forks
- 280
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 7
Description
**What is the current behavior:**
`StoreWritable.on()` reports `undefined` returned from the reducer. This doesn't look as intended behavior neither from v23 release notes, nor from documentation.
> store: undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option
https://share.effector.dev/007a4LsA
```ts
const add = createEvent();
const $v = createStore(0)
.on(add, (a, b) => {
if (b !== undefined) {
return a + b;
}
})
.watch((v) => console.log(">> $s", v));
add.watch((v) => console.log(">> add", v));
add(50);
add();
add(-8);
```
Docs:
> ## Store
>
> *Store* is an object that holds the state value. Store is getting updates when receives a value that is not equal (`!==`) to current one and to `undefined`.
> ```js
> $store.on(trigger, reducer);
> ```
> A store cannot hold an `undefined` value. If a reducer function returns `undefined`, the store will not be updated.
Release notes:
> - Deprecate undefined as magical value to skip store updates, use `skipVoid: true` option in `combine` and `map` to enable old behavior.
**What is the expected behavior:**
Using `undefined` return value from `on()` reducer looks still fine from docs and release notes, so:
- either no error should be reported
- either docs should describe better the `undefined` status for `Store`
**Which versions**
- Effector 23.0.0
Contributor guide
Assessment
This issue has not been assessed yet.