kildem (4) [Avatar] Offline
#1
I've tried the code example but I think somethings is missing:
It is possible to fix the code?

this is the code copied from the book:
https://gist.github.com/kildem/81661c7505ca6abba7bb512d778f0f71

it give me this error:
Uncaught TypeError: store.dispatch is not a function
Paul Daniels (6) [Avatar] Offline
#2
Hi,

Thanks for submitting this issue! You're right the wrong value is getting passed to the createMiddleware method.
I'll include a fix for this in the next version of the text.

In the meantime you can fix it locally by splitting the creation of the variables.

const store = createStore(simpleReducer, {messages: []})
const observableStore$ = createStreamFromStore(store);

observableStore.subscribe(({messages}) => console.log(messages.join('=>')));

const disposableDispatcher = createMiddleware(store, [simpleEpic]);



Thanks!
Paul
kildem (4) [Avatar] Offline
#3
rxjsLogs.png
[ 110 KB ]
Thanks it works now!

it prints the log message every second keeping the old state and adding the new one on the tail:

Hello=>in Rx!=>in Redux!
Hello=>in Rx!=>in Rx!=>in Redux!
Hello=>in Rx!=>in Rx!=>in Rx!=>in Redux!
Hello=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Redux!
Hello=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Redux!
Hello=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Redux!
Hello=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Redux!
Hello=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Redux!
Hello=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Redux!
Hello=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Rx!=>in Redux!
... ...
kildem (4) [Avatar] Offline
#4
In the "function createMiddleware(store, epics) {..}" the "call: combinedActions$.subscribe(input$);" create a loop therefore the same epic function is called every second. Is it a desired behavior?