Skip to content

Commit

Permalink
feat(withAtomEffect): add withAtomEffect to export
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaskasky committed Sep 16, 2024
1 parent fa0f231 commit 0706b7a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Effect

[jotai-effect](https://jotai.org/docs/integrations/effect) is a utility package for reactive side effects.
[jotai-effect](https://jotai.org/docs/extensions/effect) is a utility package for reactive side effects.

## install

Expand Down Expand Up @@ -92,7 +92,7 @@ function MyComponent() {

</details>

- **Resistent To Infinite Loops:**
- **Resistant To Infinite Loops:**
`atomEffect` does not rerun when it changes a value with `set` that it is watching.

<!-- prettier-ignore -->
Expand Down Expand Up @@ -374,7 +374,6 @@ const loggingAtom = withAtomEffect(anAtom, (get, set) => {
})
```


## Comparison with useEffect

### Component Side Effects
Expand Down
2 changes: 2 additions & 0 deletions __tests__/withAtomEffect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ describe('withAtomEffect', () => {
store.sub(enhancedAtom, () => {})
store.set(enhancedAtom, 5)
expect(store.get(enhancedAtom)).toBe(5)
store.set(enhancedAtom, (prev) => prev + 1)
expect(store.get(enhancedAtom)).toBe(6)
})

it('calls effect on initial use and on dependencies change', async () => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jotai-effect",
"description": "👻🔁",
"version": "1.0.2",
"version": "1.0.3",
"author": "David Maskasky",
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { atomEffect } from './atomEffect'
export { withAtomEffect } from './withAtomEffect'

0 comments on commit 0706b7a

Please sign in to comment.