Closed gopowerrangers closed 5 years ago
Resolved.
In the epic, I needed to remove the second return
(before the _getFirebaseTodoStrings
).
Never mind, it does not work, I was looking at the wrong thing.
But I did force it work using the following code
Could someone explain why the code above works but not the code below?
Hey there -- the first example returns a Stream<CreateTodoListFromStrings>
-- therefore, the epic will dispatch CreateTodoListFromStrings
received from that Stream. The second example returns a Stream<Stream<CreateTodoListFromStrings>>
. Therefore, the epic will emit the inner Stream<CreateTodoListFromStrings>
.
To "unwrap" the inner stream, instead of using map
, use flatMap
. For example: .ofType().flatMap(...)
.
flatMap
will subscribe to that inner Stream and emit the CreateTodoListFromStrings
actions.
Yup that fixes it.
Hi I am using the following code to sync to a Firebase real time database. After opening the Firebase stream, the Epic should send a new
CreateTodoListFromStrings
action to the reducers, which keeps the Redux TodoList synced with the database.I thought it would be enough to just return on Observable (as is shown in examples here https://medium.com/shift-studio/flutter-redux-and-firebase-cloud-firestore-in-sync-2c1accabdac4) and it was resolved into an action by the time it reaches the reducer. Other examples, including this repo's ReadMe, are returning a stream or Observable, so I assumed this pattern would work.
But according to the debugger, the reducers are receiving the Observable itself. As a result none of the reducers are activated, and the store is never updated.
Am I not thinking about this the right way?