Skip to content

Commit

Permalink
Do not log if calling context update / force update after disposal.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neloreck committed Sep 13, 2023
1 parent 9f9eadf commit d381208
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
## 4.4.0 (*/*/2023)
## 4.4.0 (9/13/2023)

### Changed

- useContextWithMemo simplified
- useContextWithMemo support of React 18 strict mode
- method calls print warning about disposal only in dev env
- method calls print warning about disposal with trace
- method calls do not print warning about disposal

## 4.3.1 (8/2/2022)

Expand Down
6 changes: 6 additions & 0 deletions src/dreamstate/core/error/nothing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Utility function placeholder to ignore all further calls.
*/
export function doNothing(): void{
// Nothing to do here.
}
6 changes: 3 additions & 3 deletions src/dreamstate/core/scoping/initializeScopeContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DreamstateError } from "@/dreamstate/core/error/DreamstateError";
import { doNothing } from "@/dreamstate/core/error/nothing";
import { throwAfterDisposal } from "@/dreamstate/core/error/throw";
import { warnSyncAfterDisposal } from "@/dreamstate/core/error/warn";
import {
QUERY_METADATA_REGISTRY,
QUERY_METADATA_SYMBOL,
Expand Down Expand Up @@ -118,8 +118,8 @@ export function initializeScopeContext(registry: IRegistry = createRegistry()):
*/
instance[SCOPE_SYMBOL] = null as TUninitializedValue;

instance["setContext"] = warnSyncAfterDisposal as TUninitializedValue;
instance["forceUpdate"] = warnSyncAfterDisposal as TUninitializedValue;
instance["setContext"] = doNothing as TUninitializedValue;
instance["forceUpdate"] = doNothing as TUninitializedValue;

/**
* Most likely code will fail with null pointer in case of warning.
Expand Down

0 comments on commit d381208

Please sign in to comment.