Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

asieduernest12
Copy link

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

value = await newValue;
subscribers.forEach((callback) => callback(value));
}

computeValue();
if (["promise", "function"].includes(getInitialType())) computeValue();
Copy link
Author

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);

Copy link
Author

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();
});

Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant