-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update: testing with vite and pnpm on stackblitz since npm not working #6
base: main
Are you sure you want to change the base?
Conversation
value = await newValue; | ||
subscribers.forEach((callback) => callback(value)); | ||
} | ||
|
||
computeValue(); | ||
if (["promise", "function"].includes(getInitialType())) computeValue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without this modifycation the code below breaks in testing
const basicAtom = atom(2)
expect(basicAtom.get()).toEqual(2)
so we can assume we only want to call computed if we are dealing with a promise or function. promise though?
async function computeValue() { | ||
const newValue = | ||
typeof initialValue === "function" | ||
? (initialValue as AtomGetter<AtomType>)(get) | ||
: value; | ||
value = (null as AtomType); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto format, can be ignored
expect(cRes).includes(newB); | ||
unsubB(); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clearing the subscribtions in the for-loop since the idea is to validate a single atom change reflects on the computed atom
Just a basic test setup to explore how the implementation behaves.
Not sure about the awaits at the end, seem confusing but obviously care must be given when dealing with computed atom results