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

refactor(utils): atomWithObservable #1426

Merged
merged 5 commits into from
Sep 19, 2022

Conversation

dai-shi
Copy link
Member

@dai-shi dai-shi commented Sep 19, 2022

close #1404

error handling was already supported, so what this PR does are:

  • add more tests with error handling.
  • better error handling code eliminating Promise.reject().
  • refactor the entire code with our recent experience with jotai/query and jotai/urql.
  • options type is slightly changed to avoid confusion.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@vercel
Copy link

vercel bot commented Sep 19, 2022

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

Name Status Preview Updated
jotai ✅ Ready (Inspect) Visit Preview Sep 19, 2022 at 7:37AM (UTC)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 19, 2022

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.

Latest deployment of this branch, based on commit 7e79ad2:

Sandbox Source
React Configuration
React Typescript Configuration
React Browserify Configuration
React Snowpack Configuration
Next.js Configuration
Next.js with custom Babel config Configuration
React with custom Babel config Configuration

initialValue?: TData | InitialValueFunction<TData>
type Options<Data> = {
initialValue?: Data | (() => Data)
timeout?: number
Copy link
Member Author

Choose a reason for hiding this comment

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

This new option is still an undocumented one. It only exists to avoid memory leaks with concurrent rendering. we are not sure what's the best practice. Hmm, maybe we should add unstable_ prefix.

@github-actions
Copy link

github-actions bot commented Sep 19, 2022

Size Change: +147 B (0%)

Total Size: 156 kB

Filename Size Change
dist/esm/utils.js 5.22 kB +32 B (+1%)
dist/system/utils.development.js 5.57 kB +36 B (+1%)
dist/system/utils.production.js 3.49 kB +1 B (0%)
dist/umd/utils.development.js 9.95 kB +28 B (0%)
dist/umd/utils.production.js 6.41 kB +19 B (0%)
dist/utils.js 9.75 kB +31 B (0%)
ℹ️ View Unchanged
Filename Size
dist/babel/plugin-debug-label.js 952 B
dist/babel/plugin-react-refresh.js 1.17 kB
dist/babel/preset.js 1.42 kB
dist/devtools.js 3.82 kB
dist/esm/babel/plugin-debug-label.js 807 B
dist/esm/babel/plugin-react-refresh.js 1.01 kB
dist/esm/babel/preset.js 1.26 kB
dist/esm/devtools.js 2.96 kB
dist/esm/immer.js 643 B
dist/esm/index.js 5.26 kB
dist/esm/optics.js 668 B
dist/esm/query.js 1.17 kB
dist/esm/redux.js 254 B
dist/esm/urql.js 1.26 kB
dist/esm/valtio.js 540 B
dist/esm/xstate.js 872 B
dist/esm/zustand.js 289 B
dist/immer.js 726 B
dist/index.js 6.29 kB
dist/optics.js 938 B
dist/query.js 1.27 kB
dist/redux.js 314 B
dist/system/babel/plugin-debug-label.development.js 917 B
dist/system/babel/plugin-debug-label.production.js 682 B
dist/system/babel/plugin-react-refresh.development.js 1.11 kB
dist/system/babel/plugin-react-refresh.production.js 869 B
dist/system/babel/preset.development.js 1.37 kB
dist/system/babel/preset.production.js 1.06 kB
dist/system/devtools.development.js 3.14 kB
dist/system/devtools.production.js 2.1 kB
dist/system/immer.development.js 772 B
dist/system/immer.production.js 469 B
dist/system/index.development.js 5.48 kB
dist/system/index.production.js 3.05 kB
dist/system/optics.development.js 770 B
dist/system/optics.production.js 455 B
dist/system/query.development.js 1.32 kB
dist/system/query.production.js 1.08 kB
dist/system/redux.development.js 344 B
dist/system/redux.production.js 217 B
dist/system/urql.development.js 1.41 kB
dist/system/urql.production.js 937 B
dist/system/valtio.development.js 652 B
dist/system/valtio.production.js 400 B
dist/system/xstate.development.js 981 B
dist/system/xstate.production.js 626 B
dist/system/zustand.development.js 377 B
dist/system/zustand.production.js 235 B
dist/umd/babel/plugin-debug-label.development.js 1.11 kB
dist/umd/babel/plugin-debug-label.production.js 844 B
dist/umd/babel/plugin-react-refresh.development.js 1.32 kB
dist/umd/babel/plugin-react-refresh.production.js 1 kB
dist/umd/babel/preset.development.js 1.56 kB
dist/umd/babel/preset.production.js 1.19 kB
dist/umd/devtools.development.js 3.94 kB
dist/umd/devtools.production.js 2.61 kB
dist/umd/immer.development.js 871 B
dist/umd/immer.production.js 570 B
dist/umd/index.development.js 6.38 kB
dist/umd/index.production.js 3.49 kB
dist/umd/optics.development.js 1.08 kB
dist/umd/optics.production.js 671 B
dist/umd/query.development.js 1.42 kB
dist/umd/query.production.js 1.1 kB
dist/umd/redux.development.js 454 B
dist/umd/redux.production.js 322 B
dist/umd/urql.development.js 5.19 kB
dist/umd/urql.production.js 3.67 kB
dist/umd/valtio.development.js 722 B
dist/umd/valtio.production.js 500 B
dist/umd/xstate.development.js 1.45 kB
dist/umd/xstate.production.js 912 B
dist/umd/zustand.development.js 479 B
dist/umd/zustand.production.js 334 B
dist/urql.js 5.01 kB
dist/valtio.js 586 B
dist/xstate.js 1.31 kB
dist/zustand.js 344 B

compressed-size-action

@dai-shi dai-shi added this to the v1.8.4 milestone Sep 19, 2022
@dai-shi dai-shi merged commit 233ac74 into main Sep 19, 2022
@dai-shi dai-shi deleted the feat/utils/atom-with-observable-error-handling branch September 19, 2022 11:33
Comment on lines +94 to +95
(d) => listener({ d }),
(e) => listener({ e })
Copy link
Member Author

Choose a reason for hiding this comment

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

Seems like this style is deprecated in rxjs. https://rxjs.dev/deprecations/subscribe-arguments

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.

[atomWithObservable] support error handling
1 participant