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

docs: add jotai-derive extension documentation #2656

Merged
merged 6 commits into from
Nov 20, 2024

Conversation

iwoplaza
Copy link
Contributor

@iwoplaza iwoplaza commented Jul 14, 2024

Related Bug Reports or Discussions

Adds documentation about an extension discussed in #2640 .

Check List

  • pnpm run prettier for formatting code and docs

Copy link

vercel bot commented Jul 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
jotai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 20, 2024 4:51am

Copy link

codesandbox-ci bot commented Jul 14, 2024

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.

Copy link

github-actions bot commented Jul 14, 2024

LiveCodes Preview in LiveCodes

Latest commit: 6446d50
Last updated: Nov 20, 2024 4:50am (UTC)

Playground Link
React demo https://livecodes.io?x=id/6C7KFSH8L

See documentations for usage instructions.

@iwoplaza iwoplaza marked this pull request as ready for review July 14, 2024 20:21
@iwoplaza iwoplaza changed the title docs: add derive extension documentation docs: add jotai-derive extension documentation Jul 14, 2024
@dai-shi
Copy link
Member

dai-shi commented Jul 14, 2024

There is a distinction between "semi-official" libs and "third-party" libs.

#2260 (comment)

Now, this is a great discussion point.
I think eventually we need some guidance about moving from a third-party to a semi-official,
and also moving the other way around.
(We could even consider having "semi-official" and "third-party" in the docs for more visibility. cc @sandren I was hoping https://github.com/jotaijs/links to work, but it doesn't.)

On the other hand, I personally think jotai-derive is worth a semi-official library. But, it also feels too new. Someone has to review the code too.

Let's see what others think. @Aslemammad @dmaskasky @arjunvegda @DavidJFelix

@dai-shi dai-shi marked this pull request as draft July 15, 2024 00:54
pipe(
soonAll(get(isAdminAtom), get(enabledAtom)),
soon(([isAdmin, enabled]) => (isAdmin && enabled ? get(queryAtom) : null))
)

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?

Copy link
Contributor Author

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

Copy link

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmaskasky dmaskasky removed their request for review July 26, 2024 18:29
@dai-shi
Copy link
Member

dai-shi commented Sep 25, 2024

Just noticed that https://github.com/jotaijs/jotai-derive is still a private repo. Is it intentional?

@iwoplaza
Copy link
Contributor Author

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! 🙌

Copy link
Member

@dai-shi dai-shi left a 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 !

@dai-shi dai-shi merged commit ad2f83c into pmndrs:main Nov 20, 2024
40 checks passed
@iwoplaza iwoplaza deleted the docs/jotai-derive branch November 20, 2024 11:17
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.

6 participants