Skip to content

Commit

Permalink
Merge pull request #4 from jotaijs/mark-atoms-private
Browse files Browse the repository at this point in the history
feat: mark internal atoms as private
  • Loading branch information
arjunvegda authored Mar 4, 2023
2 parents 0599e49 + b3067a2 commit 67a7b84
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"html-webpack-plugin": "^5.5.0",
"jest": "^29.4.1",
"jest-environment-jsdom": "^29.4.1",
"jotai": "^2.0.0",
"jotai": "^2.0.3",
"microbundle": "^0.15.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.3",
Expand Down
12 changes: 11 additions & 1 deletion src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export const createAtom = <Args, Result, Action, ActionResult>(
) => ActionResult,
) => {
const refreshAtom = atom(0);

if (process.env.NODE_ENV !== 'production') {
refreshAtom.debugPrivate = true;
}
const observableAtom = atom((get) => {
get(refreshAtom);
const args = getArgs(get);
Expand All @@ -23,12 +25,20 @@ export const createAtom = <Args, Result, Action, ActionResult>(
return observable;
});

if (process.env.NODE_ENV !== 'production') {
observableAtom.debugPrivate = true;
}

const baseDataAtom = atom((get) => {
const observable = get(observableAtom);
const resultAtom = atomWithObservable(() => observable);
return resultAtom;
});

if (process.env.NODE_ENV !== 'production') {
baseDataAtom.debugPrivate = true;
}

const dataAtom = atom(
(get) => {
const resultAtom = get(baseDataAtom);
Expand Down
4 changes: 4 additions & 0 deletions src/environmentAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ const defaultEnvironment = new Environment({
});

export const environmentAtom = atom(defaultEnvironment);

if (process.env.NODE_ENV !== 'production') {
environmentAtom.debugPrivate = true;
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5162,10 +5162,10 @@ jest@^29.4.1:
import-local "^3.0.2"
jest-cli "^29.4.1"

jotai@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/jotai/-/jotai-2.0.0.tgz#3938ad0166130417811bb57ec2de8abeb24bd948"
integrity sha512-04G0CRZQgp3xrFAezd6X14psZ2TRGekHeYMBcbDJ/BR8ZJQPS+j0YkMTxUxyG58HJnN2+adfj5sWQWoqgtp1XQ==
jotai@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/jotai/-/jotai-2.0.3.tgz#3b67cda9f6d5feb70a14db0b842a9873aacda8b5"
integrity sha512-MMjhSPAL3RoeZD9WbObufRT2quThEAEknHHridf2ma8Ml7ZVQmUiHk0ssdbR3F0h3kcwhYqSGJ59OjhPge7RRg==

js-sdsl@^4.1.4:
version "4.3.0"
Expand Down

0 comments on commit 67a7b84

Please sign in to comment.