atom.io 0.33.18 → 0.33.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +6 -0
- package/dist/internal/index.js.map +1 -1
- package/dist/main/index.d.ts +4 -0
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js.map +1 -1
- package/dist/react-devtools/index.js +2 -2
- package/dist/react-devtools/index.js.map +1 -1
- package/package.json +3 -3
- package/src/internal/atom/create-regular-atom.ts +4 -1
- package/src/internal/mutable/create-mutable-atom.ts +4 -1
- package/src/internal/set-state/reset-atom-or-selector.ts +2 -1
- package/src/main/atom.ts +4 -0
- package/src/react-devtools/store.ts +1 -2
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
UpdateHandler,
|
|
6
6
|
} from "atom.io"
|
|
7
7
|
|
|
8
|
-
import { type RegularAtom, setIntoStore } from ".."
|
|
8
|
+
import { type RegularAtom, resetInStore, setIntoStore } from ".."
|
|
9
9
|
import { cacheValue } from "../caching"
|
|
10
10
|
import { newest } from "../lineage"
|
|
11
11
|
import type { Store } from "../store"
|
|
@@ -62,6 +62,9 @@ export function createRegularAtom<T>(
|
|
|
62
62
|
const cleanupFunctions: (() => void)[] = []
|
|
63
63
|
for (const effect of options.effects) {
|
|
64
64
|
const cleanup = effect({
|
|
65
|
+
resetSelf: () => {
|
|
66
|
+
resetInStore(store, token)
|
|
67
|
+
},
|
|
65
68
|
setSelf: (next) => {
|
|
66
69
|
setIntoStore(store, token, next)
|
|
67
70
|
},
|
|
@@ -8,7 +8,7 @@ import type { Json } from "atom.io/json"
|
|
|
8
8
|
import { selectJson } from "atom.io/json"
|
|
9
9
|
|
|
10
10
|
import type { MutableAtom } from ".."
|
|
11
|
-
import { cacheValue, setIntoStore } from ".."
|
|
11
|
+
import { cacheValue, resetInStore, setIntoStore } from ".."
|
|
12
12
|
import { newest } from "../lineage"
|
|
13
13
|
import { deposit, type Store } from "../store"
|
|
14
14
|
import { Subject } from "../subject"
|
|
@@ -65,6 +65,9 @@ export function createMutableAtom<
|
|
|
65
65
|
const cleanupFunctions: (() => void)[] = []
|
|
66
66
|
for (const effect of options.effects) {
|
|
67
67
|
const cleanup = effect({
|
|
68
|
+
resetSelf: () => {
|
|
69
|
+
resetInStore(store, token)
|
|
70
|
+
},
|
|
68
71
|
setSelf: (next) => {
|
|
69
72
|
setIntoStore(store, token, next)
|
|
70
73
|
},
|
package/src/main/atom.ts
CHANGED
|
@@ -40,6 +40,10 @@ export function atom(
|
|
|
40
40
|
|
|
41
41
|
/** @public */
|
|
42
42
|
export type Effectors<T> = {
|
|
43
|
+
/**
|
|
44
|
+
* Reset the value of the atom to its default
|
|
45
|
+
*/
|
|
46
|
+
resetSelf: () => void
|
|
43
47
|
/**
|
|
44
48
|
* Set the value of the atom
|
|
45
49
|
* @param next - The new value of the atom, or a setter function
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
createAtomFamily,
|
|
10
10
|
createStandaloneAtom,
|
|
11
11
|
createTransaction,
|
|
12
|
-
IMPLICIT,
|
|
13
12
|
type Store,
|
|
14
13
|
} from "atom.io/internal"
|
|
15
14
|
import type {
|
|
@@ -186,4 +185,4 @@ export function attachDevtoolsStates(
|
|
|
186
185
|
|
|
187
186
|
export const DevtoolsContext: Context<
|
|
188
187
|
DevtoolsStates & IntrospectionStates & { store: Store }
|
|
189
|
-
> = createContext(
|
|
188
|
+
> = createContext({})
|