stream-chat-js
stream-chat-js copied to clipboard
fix: change subscribeWithSelector API declaration
CLA
As discussed with @oliverlaz and @arnautov-anton , the current API of the state store seems very brittle for integrators and something that is very prone to errors (that we cannot easily catch). Because of that, we've decided to change the state store's API so that it no longer returns an array of sorted properties, but rather an object with named properties.
The way the API changes is as follows:
Previously:
const selector = (nextValue: SomeState) => [nextValue.nameFromState] as const;
const selector = (nextValue: SomeState) => ({ explicitName: nextValue.nameFromState } as const);
and then use it by:
const { explicitName } = { ... }
This way, we will never be completely dependant on keeping the order of the array proper and not have to worry about adding new properties to maintain the order.
- [ ] I have signed the Stream CLA (required).
- [ ] Code changes are tested
Description of the changes, What, Why and How?
Changelog
Size Change: +574 B (+0.13%)
Total Size: 428 kB
| Filename | Size | Change |
|---|---|---|
dist/browser.es.js |
92.8 kB | +111 B (+0.12%) |
dist/browser.full-bundle.min.js |
54.3 kB | +129 B (+0.24%) |
dist/browser.js |
93.9 kB | +109 B (+0.12%) |
dist/index.es.js |
92.8 kB | +113 B (+0.12%) |
dist/index.js |
93.9 kB | +112 B (+0.12%) |