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

bug: initialState function not working for deep object mutations #227

Open
3 tasks done
bordagabor opened this issue Mar 6, 2023 · 1 comment
Open
3 tasks done
Labels

Comments

@bordagabor
Copy link

Prerequisites

Stencil Store Version

2.0.4

Stencil Version

3.0.0

Current Behavior

According to the documentation, the initialState property can be a function that returns the actual initial state. This is useful for cases where we have deep objects that mutate, as the library is unable to track those changes otherwise. However, I have found that this feature does not seem to be working as expected.
Also, the typing is not correct - the exported state is treated as a function in case I pass function to the createStore

Expected Behavior

When using a function as the initialState, changes to deep objects should be reactive and properly tracked and updated by the library.

Steps to Reproduce

  1. Create store with the createStore function and pass a function which is return with the initialState according to the docs.
  2. Observe that changes to the deep object are not being tracked as expected.

Code Reproduction URL

https://codesandbox.io/p/sandbox/happy-kowalevski-vi29n6

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Mar 6, 2023
@antho686
Copy link

antho686 commented Aug 17, 2023

Just wanted to up on this Ticket. I checked the code and it seems there's a mis-typing in the createStore function. View here
The defaultState has been typed as T but is passed to the createObservableMap which is expecting a Invocable<T> compare with this line.
I could open a PR to fix the typings if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants