GuillaumeSalles / redux.NET

Redux.NET is a predictable state container for .NET apps. Inspired by https://github.com/reactjs/redux.
713 stars 87 forks source link

What is the point of this Redux.NET line #49

Closed cmeeren closed 7 years ago

cmeeren commented 7 years ago

What is the point of this line? I.e., what is the point of calling _stateSubject.OnNext(_lastState); at the end of the Store constructor? My understanding is that it calls any subscriber callbacks (like firing an event). However, I assume it's not possible for anyone to subscribe to the Store before the constructor has finished, so I can't see how it's doing anything.

GuillaumeSalles commented 7 years ago

If you remove this line, the initial state will not be pushed at first subscription.

If I remember correctly, this test will fail if you remove it.

GuillaumeSalles commented 7 years ago

Maybe I'll push a new version without the Subject to clarify the code, if some people are interested.

cmeeren commented 7 years ago

Ah, I see, it has to do with the workings of the reactive stuff. Thanks!