Updated initSplitSdk action creator to attach event listeners only once (not when the thunk action is dispatched). This is needed for server-side, where initSplitSdk is called once but the created thunk is dispatched each time a new store is created per request/session.
Updated destroySplitSdk action creator to shut down the SDK before the thunk action is dispatched. This is needed for server-side, where destroySplitSdk is invoked without dispatching the thunk action.
Added onDestroy callback parameter to destroySplitSdk, to listen when the SDK has gracefully shut down. This param is mainly needed for server-side, where the thunk action is not dispatched and so the user cannot access the destroy promise as in client-side: store.dispatch(destroySplitSdk()).then(...).
How do we test the changes introduced in this PR?
E2E test to evaluate that event callbacks are invoked only once when initSplitSdk thunk is dispatched multiple times.
E2E test to evaluate that onDestroy callback is invoked even when the returned destroySplitSdk thunk action is not dispatched.
Extra Notes
[DONE: onDestroy invoked preferably after action is dispatched] define if onDestroy callback must be invoked after splitDestroy action is dispatched or not.
Redux SDK
What did you accomplish?
Updated
initSplitSdk
action creator to attach event listeners only once (not when the thunk action is dispatched). This is needed for server-side, whereinitSplitSdk
is called once but the created thunk is dispatched each time a new store is created per request/session.Updated
destroySplitSdk
action creator to shut down the SDK before the thunk action is dispatched. This is needed for server-side, wheredestroySplitSdk
is invoked without dispatching the thunk action.Added
onDestroy
callback parameter todestroySplitSdk
, to listen when the SDK has gracefully shut down. This param is mainly needed for server-side, where the thunk action is not dispatched and so the user cannot access the destroy promise as in client-side:store.dispatch(destroySplitSdk()).then(...)
.How do we test the changes introduced in this PR?
initSplitSdk
thunk is dispatched multiple times.onDestroy
callback is invoked even when the returneddestroySplitSdk
thunk action is not dispatched.Extra Notes
onDestroy
callback must be invoked aftersplitDestroy
action is dispatched or not.