Skip to content

Commit

Permalink
fix atomWithBroadcast description (#2106)
Browse files Browse the repository at this point in the history
  • Loading branch information
AjaxSolutions authored Sep 4, 2023
1 parent 5e5a5e6 commit 90a3116
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions docs/recipes/atom-with-broadcast.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ keywords: creators,broadcast
> browser tabs and frames, similar to `atomWithStorage` but with the
> initialization limitation.
This can be useful when you want the state to interact with each other without
the use of localStorage and that by just using The Broadcast Channel API allows
basic communication between browsing contexts (that is, windows, tabs, frames,
create a component or iframes) and workers on the same origin. According to the MDN documentation receiving a message in initialization is not supported in broadcast and if we want to support that we may need to add extra stuff to atomWithBroadcast (like local storage).
This can be useful when you want states to interact with each other without the use of localStorage.
By using the BroadcastChannel API, you can enable basic communication between browsing contexts such as windows, tabs, frames, components, or iframes, and workers on the same origin.
According to the MDN documentation, receiving a message during initialization is not supported in the BroadcastChannel, but if you want to support that functionality, you may need to add extra option to atomWithBroadcast, such as local storage.

```tsx
import { atom } from 'jotai'
Expand Down

1 comment on commit 90a3116

@vercel
Copy link

@vercel vercel bot commented on 90a3116 Sep 4, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.