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

Return Store and StoreWritable<T> whenever it is meaningful #275

Closed
agadoev opened this issue Feb 25, 2023 · 4 comments
Closed

Return Store and StoreWritable<T> whenever it is meaningful #275

agadoev opened this issue Feb 25, 2023 · 4 comments
Labels
BREAKING CHANGES Some features changes without backward compatibility
Milestone

Comments

@agadoev
Copy link

agadoev commented Feb 25, 2023

Now in the documentation and reshape function signature return value is Store, but in fact it is ReadonlyStore. It can be reproduced by decomposing some stores with reshape and trying to modify it with .on(). An error message will appear in the browser console.

I suggest explicitly defining ReadonlyStore type as the return value of reshape function.

@agadoev
Copy link
Author

agadoev commented Feb 25, 2023

now this code

const { $part1, $part2 } = reshape({
  source: $complexData,
  shape: {
    $part1: (complexData) => complexData.part1,
    $part2: (complexData) => complexData.part2
  }
})

is the same as this code

const $part1 = $complexData.map(complexData => complexData.part1)
const $part2 = $complexData.map(complexData => complexData.part2)

I think it would be really useful if reshape returned a simple store, changing which would cause the parent store changes.

@sergeysova
Copy link
Member

sergeysova commented Feb 28, 2023

@agadoev At the moment effector has no defined ReadonlyStore.

https://github.com/effector/effector/blob/master/packages/effector/index.d.ts

It will be possible only after this change.
Keep track of effector/effector#755

@sergeysova sergeysova added this to the v2.0 milestone Feb 28, 2023
@sergeysova sergeysova added the BREAKING CHANGES Some features changes without backward compatibility label Feb 28, 2023
@sergeysova sergeysova changed the title change reshape return value to DerivedStore Return DerivedStore whenever it is meaningful Feb 28, 2023
@sergeysova sergeysova mentioned this issue Feb 28, 2023
35 tasks
@sergeysova sergeysova changed the title Return DerivedStore whenever it is meaningful Return ReadonlyStore whenever it is meaningful Jun 10, 2023
@sergeysova sergeysova changed the title Return ReadonlyStore whenever it is meaningful Return Store and StoreWritable<T> whenever it is meaningful Jul 6, 2023
@sergeysova
Copy link
Member

Store renamed into StoreWritable, but ReadonlyStore renamed into Store

@sergeysova
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BREAKING CHANGES Some features changes without backward compatibility
Projects
None yet
Development

No branches or pull requests

2 participants