stockroom
stockroom copied to clipboard
WIP: Subscribers now receive update & params
has https://github.com/developit/unistore/pull/167 dependency
How does this work with batching though?
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
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.