Skip to content

Conversation

@dai-shi
Copy link
Member

@dai-shi dai-shi commented Jan 18, 2026

loadable is deprecated infavor of unwrap.

Userland implementation of loadable:

function loadable(anAtom) {
  const LOADING = { state: 'loading' }
  const unwrappedAtom = unwrap(anAtom, () => LOADING)
  return atom((get) => {
    try {
      const data = get(unwrappedAtom)
      if (data === LOADING) {
        return LOADING
      }
      return { state: 'hasData', data }
    } catch (error) {
      return { state: 'hasError', error }
    }
  })
}

@vercel
Copy link

vercel bot commented Jan 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
jotai Ready Ready Preview, Comment Jan 19, 2026 2:10pm

Request Review

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 18, 2026

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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 18, 2026

More templates

npm i https://pkg.pr.new/jotai@3217

commit: 67a1f84

@github-actions
Copy link

github-actions bot commented Jan 18, 2026

Size Change: -343 B (-0.35%)

Total Size: 98.5 kB

Filename Size Change
./dist/esm/vanilla/utils.mjs 5.2 kB -56 B (-1.07%)
./dist/system/vanilla/utils.development.js 5.39 kB -63 B (-1.15%)
./dist/system/vanilla/utils.production.js 3.11 kB -89 B (-2.78%)
./dist/umd/vanilla/utils.development.js 6.45 kB -36 B (-0.56%)
./dist/umd/vanilla/utils.production.js 3.76 kB -66 B (-1.73%)
./dist/vanilla/utils.js 6.33 kB -33 B (-0.52%)
ℹ️ View Unchanged
Filename Size
./dist/babel/plugin-debug-label.js 932 B
./dist/babel/plugin-react-refresh.js 1.14 kB
./dist/babel/preset.js 1.41 kB
./dist/esm/babel/plugin-debug-label.mjs 1 kB
./dist/esm/babel/plugin-react-refresh.mjs 1.19 kB
./dist/esm/babel/preset.mjs 1.49 kB
./dist/esm/index.mjs 62 B
./dist/esm/react.mjs 1.59 kB
./dist/esm/react/utils.mjs 746 B
./dist/esm/utils.mjs 67 B
./dist/esm/vanilla.mjs 666 B
./dist/esm/vanilla/internals.mjs 4.2 kB
./dist/index.js 242 B
./dist/react.js 1.53 kB
./dist/react/utils.js 1.4 kB
./dist/system/babel/plugin-debug-label.development.js 1.1 kB
./dist/system/babel/plugin-debug-label.production.js 780 B
./dist/system/babel/plugin-react-refresh.development.js 1.29 kB
./dist/system/babel/plugin-react-refresh.production.js 932 B
./dist/system/babel/preset.development.js 1.59 kB
./dist/system/babel/preset.production.js 1.15 kB
./dist/system/index.development.js 252 B
./dist/system/index.production.js 185 B
./dist/system/react.development.js 1.77 kB
./dist/system/react.production.js 966 B
./dist/system/react/utils.development.js 859 B
./dist/system/react/utils.production.js 465 B
./dist/system/utils.development.js 257 B
./dist/system/utils.production.js 190 B
./dist/system/vanilla.development.js 736 B
./dist/system/vanilla.production.js 349 B
./dist/system/vanilla/internals.development.js 4.29 kB
./dist/system/vanilla/internals.production.js 2.81 kB
./dist/umd/babel/plugin-debug-label.development.js 1.08 kB
./dist/umd/babel/plugin-debug-label.production.js 851 B
./dist/umd/babel/plugin-react-refresh.development.js 1.27 kB
./dist/umd/babel/plugin-react-refresh.production.js 1 kB
./dist/umd/babel/preset.development.js 1.54 kB
./dist/umd/babel/preset.production.js 1.22 kB
./dist/umd/index.development.js 383 B
./dist/umd/index.production.js 327 B
./dist/umd/react.development.js 1.66 kB
./dist/umd/react.production.js 1.05 kB
./dist/umd/react/utils.development.js 1.54 kB
./dist/umd/react/utils.production.js 1.02 kB
./dist/umd/utils.development.js 399 B
./dist/umd/utils.production.js 340 B
./dist/umd/vanilla.development.js 793 B
./dist/umd/vanilla.production.js 402 B
./dist/umd/vanilla/internals.development.js 5.64 kB
./dist/umd/vanilla/internals.production.js 3.64 kB
./dist/utils.js 247 B
./dist/vanilla.js 685 B
./dist/vanilla/internals.js 5.48 kB

compressed-size-action

@github-actions
Copy link

github-actions bot commented Jan 18, 2026

LiveCodes Preview in LiveCodes

Latest commit: 67a1f84
Last updated: Jan 19, 2026 2:10pm (UTC)

Playground Link
React demo https://livecodes.io?x=id/93VVVJ7V6

See documentations for usage instructions.

@dai-shi dai-shi marked this pull request as ready for review January 18, 2026 06:58

const LOADING: Loadable<unknown> = { state: 'loading' }

export function loadable<Value>(anAtom: Atom<Value>): Atom<Loadable<Value>> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we deprecate loadable now?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking of doing it with another step, but yeah we can do that now. Let me try.

@dai-shi dai-shi changed the title refactor(utils): loadable deprecate loadable util Jan 19, 2026
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.

3 participants