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

store should support falsey state #880

Closed
jbedard opened this issue Mar 2, 2018 · 2 comments
Closed

store should support falsey state #880

jbedard opened this issue Mar 2, 2018 · 2 comments

Comments

@jbedard
Copy link
Contributor

jbedard commented Mar 2, 2018

I'm submitting a...

[X] Bug report  

What is the current behavior?

Feature store/reducers with a falsey state fallback to the initial state. This might only be for feature and not root reducers?

See

state || initialState,
where state || initialState is used.

Expected behavior:

Any non-undefined state value should be considered "set" and not be reset to the initialState.

state || initialState,
should be changed to (state !== undefined) ? state : initialState

Minimal reproduction of the problem with instructions:

Can create one if necessary...?

Version of affected browser(s),operating system(s), npm, node and ngrx:

I'm using 5.x

Other information:

As an example... in my case this feature-store represents the user session. An empty store value (undefined) means the session state is unknown (not fetched yet), a null value means no session exists and a Session object means the user is logged in. In this case the null value is being converted to undefined.

@jbedard
Copy link
Contributor Author

jbedard commented Mar 2, 2018

Actually... should initialState be the initial state, or the default state? Is it correct that an undefined store value should always be converted to the initialState like the feature store does (in one case) today?

@brandonroberts
Copy link
Member

Fixed via #886

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

No branches or pull requests

2 participants