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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

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: +261 B (+0.06%)

Total Size: 427 kB

Filename Size Change
dist/browser.es.js 92.7 kB +47 B (+0.05%)
dist/browser.full-bundle.min.js 54.2 kB +88 B (+0.16%)
dist/browser.js 93.8 kB +39 B (+0.04%)
dist/index.es.js 92.7 kB +46 B (+0.05%)
dist/index.js 93.9 kB +41 B (+0.04%)

compressed-size-action

src/store.ts Outdated Show resolved Hide resolved
src/store.ts Outdated Show resolved Hide resolved
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