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

Why stateChanged: Observable<any>? #39

Closed
GustavoCostaW opened this issue Sep 4, 2019 · 3 comments

Comments

@GustavoCostaW
Copy link

@GustavoCostaW GustavoCostaW commented Sep 4, 2019

public stateChanged: Observable<any>;

why

stateChanged: Observable<any>?

instead of:

stateChanged: Observable<T>?

Why the generic type passed is not used in the state changes observable type return?

In this case above, I can't take advantages as vscode autocomplete, I needed to create another observable called stageChanges specifying the Observable returned type to have this feature:

Screen Shot 2019-09-04 at 19 29 31

subscribing into stageChanges instead stageChanged, and then I have the autocomplete,

Screen Shot 2019-09-04 at 19 37 25

I was thinking about to send a PR but maybe there is a reason for it.

Are there any reasons why there is no generics usage?

@DanWahlin

This comment has been minimized.

Copy link
Owner

@DanWahlin DanWahlin commented Sep 4, 2019

Someone else asked about this awhile neck as well:

#6

Users can define a stateSliceSelector() function which can return a slice of state from the store when the state changes. Since there's no way to know what they'll pass back if that function is defined (it's optional, but has to be considered for this scenario), using T wasn't an option.

I normally define the type when subscribing which removes the need for what you mention above.

I'm open to ideas though if you come up with a way to handle that while preserving the functionality of the stateSliceSelector() option.

@DanWahlin

This comment has been minimized.

Copy link
Owner

@DanWahlin DanWahlin commented Oct 6, 2019

As an update, version 2 is going to go with stateChanged: Observable<T>. People using the slice functionality can cast to their own type when subscribing. Thanks for the suggestion. I’m hoping to release v2 soon.

@DanWahlin

This comment has been minimized.

Copy link
Owner

@DanWahlin DanWahlin commented Oct 13, 2019

v2 of Observable Store is out and it changes the stateChanged type as mentioned above. Give it a try when you get time.

@DanWahlin DanWahlin closed this Oct 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.