Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change subscribeWithSelector API declaration #1382

Merged
merged 7 commits into from
Oct 28, 2024

Conversation

isekovanic
Copy link
Contributor

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

Copy link
Contributor

github-actions bot commented Oct 25, 2024

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

src/store.ts Outdated Show resolved Hide resolved
src/store.ts Outdated Show resolved Hide resolved
src/store.ts Outdated Show resolved Hide resolved
@isekovanic isekovanic merged commit 5b1c7e5 into master Oct 28, 2024
5 checks passed
@isekovanic isekovanic deleted the fix/state-store-selector-api-signature branch October 28, 2024 14:29
@github-actions github-actions bot mentioned this pull request Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants