[Dev] TeactN: Assert when setting global asynchronously (follow-up)

This commit is contained in:
Alexander Zinchuk 2022-04-09 02:53:44 +02:00
parent 91c2015052
commit 7d09556e4c
2 changed files with 3 additions and 6 deletions

View File

@ -6,10 +6,7 @@ import { cloneDeep } from '../util/iteratees';
initCache();
addActionHandler('init', (global) => {
addActionHandler('init', () => {
const initial = cloneDeep(INITIAL_STATE);
return {
...global,
...(loadCache(initial) || initial),
};
return loadCache(initial) || initial;
});

View File

@ -71,7 +71,7 @@ function runCallbacks(forceOnHeavyAnimation = false) {
export function setGlobal(newGlobal?: GlobalState, options?: ActionOptions) {
if (typeof newGlobal === 'object' && newGlobal !== currentGlobal) {
if (DEBUG) {
if (newGlobal.DEBUG_id !== DEBUG_currentGlobalId) {
if (newGlobal.DEBUG_id && newGlobal.DEBUG_id !== DEBUG_currentGlobalId) {
throw new Error('[TeactN.setGlobal] Attempt to set an outdated global');
}
}