-
Notifications
You must be signed in to change notification settings - Fork 35
Seems to be backwards #451
-
Hi all. While working on a stream-chat integration I noticed the following lines in the channel service js file.
const prevChannels = recoverState ? [] : this.channelsSubject.getValue() || []; this.channelsSubject.next([...prevChannels, ...channels]);
In the queryChannels function parameters the recoverState
defaults to false
. When we are updating the channels subject, there's a part where we check if the recoverState
parameter is true
.
What I'm pointing out here might sound silly but it's confusing if you're reading the code.
"recovering" the state suggests that the dev. wants to go back to a previous state...
but on this line const prevChannels = recoverState ? [] : this.channelsSubject.getValue() || [];
the recoverState
being set to true
indicates that prevChannels
would be loading an empty array and if false
it would be going back to the previous state.
This line would make sense if written as such:
const prevChannels = recoverState ? this.channelsSubject.getValue() || [] : [];
Or maybe the developer's true intention here was to reset the State in which case, renaming the recoverState
parameter to resetState
would be the correct answer.
I hope this makes sense. Please feel free to disagree.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
Hi,
The recoverState
flag is an internal flag, not part of the public API. It is used when we recover the state after a reconnection, in those cases, we're rebuilding the whole state.
Beta Was this translation helpful? Give feedback.