-
-
Notifications
You must be signed in to change notification settings - Fork 622
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
docs: add jotai-derive
extension documentation
#2656
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Preview in LiveCodesLatest commit: 6446d50
See documentations for usage instructions. |
jotai-derive
extension documentation
There is a distinction between "semi-official" libs and "third-party" libs. Now, this is a great discussion point. On the other hand, I personally think Let's see what others think. @Aslemammad @dmaskasky @arjunvegda @DavidJFelix |
docs/extensions/derive.mdx
Outdated
pipe( | ||
soonAll(get(isAdminAtom), get(enabledAtom)), | ||
soon(([isAdmin, enabled]) => (isAdmin && enabled ? get(queryAtom) : null)) | ||
) |
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.
Out of interest, how would these examples be written as normal procedural-looking JavaScript without usage of remeda
?
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.
Here is the example in question, with remeda
removed.
import { soon, soonAll } from 'jotai-derive';
// Atom<RestrictedItem | Promise<RestrictedItem>>
const queryAtom = ...;
// Atom<boolean | Promise<boolean>>
const isAdminAtom = ...;
// Atom<boolean | Promise<boolean>>
const enabledAtom = ...;
// Atom<null | RestrictedItem | Promise<null | RestrictedItem>>
const restrictedItemAtom = atom((get) => {
const dependencies = soonAll(get(isAdminAtom), get(enabledAtom));
return soon(
dependencies,
([isAdmin, enabled]) => (isAdmin && enabled ? get(queryAtom) : null)
);
});
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.
Would love to see this non-remeda example added to the documentation, as it was very foggy on how to use this without remeda
during my initial investigation.
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.
Does README help meanwhile? https://github.com/jotaijs/jotai-derive/blob/main/README.md
Just noticed that https://github.com/jotaijs/jotai-derive is still a private repo. Is it intentional? |
@dai-shi Definitely an oversight on my part, it's public now! 🙌 |
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.
Yeah, it feels more comfortable under the third-party category. Thanks @sandren !
Related Bug Reports or Discussions
Adds documentation about an extension discussed in #2640 .
Check List
pnpm run prettier
for formatting code and docs