remote-redux-devtools: Problem with multiple stores (redux-saga)

Hi, I use multiple stores on a serverside Redux projects. I also use the redux-saga middleware.

When I enable remote-redux-devtools, I get a mixup of states. It seems the middleware is merging all actions dispatched on any store into the last store. I only see the latest store in remotedev.io and the redux generator function (main) of the last store seems to “take” all the actions.

I initialize with different names for the “instances”, all in the same process.

Could there be an issue with multiple remote-redux-devtools in the same process, or something with sagas?

I tried deleting the node “require-cache” between calls, to no avail.

My source (typescript) below, work in progress. I have commented out the devtools and things work perfectly.

const RemoteDevTools = require('remote-redux-devtools')
const {composeWithDevTools} = RemoteDevTools

function* mainLoop() : any {
	const {scenarioId} = yield take(SET_SCENARIO)
	console.log("got scenario: ", scenarioId)
	const channel = yield actionChannel('*')
	yield delay(2000)
	yield put(initialized())
	const testState = (yield select()) as IState
	console.log(`state scenario: ${testState.initialized.scenarioId}`)
	while (true) {
		const action = yield take(channel)
		console.log(`got action (${scenarioId}): `, action)
	}
}

export function createScenarioStore(scenarioId: string) {

	// This causes the remote dev tool to use remotedev.io, which can be accessed at remotedev.io/local
	const composeEnhancers = composeWithDevTools({ realtime: true, name: `scenario_${scenarioId}` }) 
	
	const middleware = createSagaMiddleware()
	const store = createStore(mainReducer, applyMiddleware(middleware)) // composeEnhancers(applyMiddleware(middleware)))

	middleware.run(mainLoop)
	store.dispatch(setScenario(scenarioId))

	return store
}

BTW: This project / tool is absolutely excellent!

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 2
  • Comments: 21 (10 by maintainers)

Most upvoted comments

Hi just to give an update. I have a feeling I have a very unique problem in that I’m currently running both stores from the same remote-redux-devtools node module. It then occurred to me that the module is a singeton and that would explain why using composeWithDevtools was causing conflicts between my two stores.