Skip to content

Is there a way to force a scope to be provided? #56

Answered by scamden
scamden asked this question in Q&A
Discussion options

You must be logged in to vote

Answered my own question.

const myScope = createScope<string | undefined>(undefined);
const myMolecule = molecule(() => {
  const scope = use(myScope);
  if (!scope) {
    throw new Error("scope is undefined");
  }
  const countAtom = atom(0);
  return {
    countAtom: countAtom,
  };
});

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by scamden
Comment options

You must be logged in to vote
2 replies
@loganvolkers
Comment options

@scamden
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants