GetStream / stream-chat-js

JS / Browser Client - Build Chat with GetStream.io
https://getstream.io/chat/
Other
183 stars 77 forks source link

fix: change subscribeWithSelector API declaration #1382

Closed isekovanic closed 4 weeks ago

isekovanic commented 1 month ago

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.

Description of the changes, What, Why and How?

Changelog

-

github-actions[bot] commented 1 month ago

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%)

compressed-size-action