Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Subscribers now receive update & params #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

krzepah
Copy link

@krzepah krzepah commented Aug 6, 2019

has developit/unistore#167 dependency

@developit
Copy link
Owner

How does this work with batching though?

@krzepah
Copy link
Author

krzepah commented Aug 6, 2019

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
Copy link
Author

krzepah commented Aug 14, 2019

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 krzepah changed the title Subscribers now receive update & params WIP: Subscribers now receive update & params Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants