stockroom icon indicating copy to clipboard operation
stockroom copied to clipboard

WIP: Subscribers now receive update & params

Open krzepah opened this issue 5 years ago • 3 comments

has https://github.com/developit/unistore/pull/167 dependency

krzepah avatar Aug 06 '19 01:08 krzepah

How does this work with batching though?

developit avatar Aug 06 '19 01:08 developit

I expended the should invoke action in the worker & update both states test to try some batching in there. I'm not sure this is answering correctly to your question, I recon I haven't tough about it that much : /

Do you have an idea of how I should stress it a little more ?

		it('should batch actions', async () => {
			postMessage.reset();

			let increment = store.action('increment');
			increment({ x: 'y' });
			increment({ x: 'y' });

			await sleep(10);

			expect(postMessage).to.have.been.calledOnce.and.calledWith([
				{ type: '@@ACTION', action: { type: 'increment', params: [{ x: 'y' }] } },
				{ type: '@@ACTION', action: { type: 'increment', params: [{ x: 'y' }] } }
			]);

			let state = await worker.getState();

			expect(state, 'worker state').to.have.property('count', 4);
			expect(store.getState(), 'main thread state').to.have.property('count', 4);
		});

note : 4 because the previous test already sets it to 2

krzepah avatar Aug 06 '19 16:08 krzepah

Hei,

Pretty sure the PR is buggy, I've problems when a project is built. I will need to dig in to find what's happening,

"tagging" it as WIP until then

edit : oops ! actually I now have an e2e test passing that uses setState with this PR ! I'm going to work more on it 🎉 the problem resorbed by itself so I guess I was doing something wrong.

krzepah avatar Aug 14 '19 21:08 krzepah