Skip to content

Conversation

@jennkao
Copy link
Contributor

@jennkao jennkao commented May 2, 2021

Following up on issue #77, this PR creates a new enhancer called synchronizeStore that wraps a Redux store in a synchronization object.

I wrote a couple tests to compare the original thread-safe store implementation that we were working with against the proposed method of using the synchronizeStore enhancer. The test involves thunk middleware as well as delays to mimic async thunks, and the test for the original implementation intermittently fails with the same error we were seeing in our setup. Notably, when using a breakpoint on line 105 of the CreateThreadSafeStoreSpec file and running the test for the original implementation in debug mode, I see that we step into the interface defs of the original store methods in CreateStore; doing the same with the test for the enhancer implementation sees us step into the interface defs of the synchronized store in SynchronizedStore. This suggests to me that with the original implementation, thunks might be accessing the unsynchronized store dispatch method.

The failing test was written just for communicating the issue we were seeing, happy to remove this and/or change up the tests as you see fit. This is my first time contributing to this repo so please let me know if I missed anything in terms of contributing standards. Thanks!


* @returns {StoreEnhancer} A store enhancer that synchronizes the store.
*/
fun <State> synchronizeStore(): StoreEnhancer<State> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more descriptive name such as createSynchronizedStoreEnhancer or syncronizedStoreEnhancer to make it clear this creates and returns a StoreEnhancer and update docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patjackson52 updated name to createSynchronizedStoreEnhancer

@jennkao jennkao force-pushed the jenn/threadsafe-enhancer branch from 616e8bf to 704a71b Compare August 4, 2021 03:37
@jennkao
Copy link
Contributor Author

jennkao commented Aug 4, 2021

I removed the failing test that was used to communicate the issue with createThreadSafeStore and have left only the test that uses createSynchronizedStoreEnhancer

@jennkao jennkao requested a review from patjackson52 August 4, 2021 03:44
@patjackson52
Copy link
Contributor

@jennkao ktlint is failing with some unused imports.

`createSynchronizedStoreEnhancer` generates a store enhancer that wraps a Redux store in a synchronization object, causing access to store methods to be synchronized. Recommended usecase is when using a thread-safe store with enhancers or middleware that require access to store methods.
@jennkao jennkao force-pushed the jenn/threadsafe-enhancer branch from 704a71b to fa1230b Compare August 10, 2021 04:50
@jennkao jennkao force-pushed the jenn/threadsafe-enhancer branch from fa1230b to d2b6e15 Compare August 10, 2021 05:09
@jennkao
Copy link
Contributor Author

jennkao commented Sep 16, 2021

hey @patjackson52 - following up here, do I need to do anything to get the checks to rerun?

@patjackson52 patjackson52 merged commit fcd8a87 into reduxkotlin:master Sep 21, 2021
@patjackson52
Copy link
Contributor

@jennkao merged and the snapshots are published. Would you be interested in making a PR to bump the version so we can publish release artifacts?

@jennkao
Copy link
Contributor Author

jennkao commented Sep 24, 2021

@patjackson52 yeah sure thing! opened a PR here - #91

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