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.
@@ -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
  },
@@ -1,4 +1,5 @@
1
- import { type Atom, traceAllSelectorAtoms, type WritableState } from ".."
1
+ import type { Atom, WritableState } from ".."
2
+ import { traceAllSelectorAtoms } from ".."
2
3
  import type { Store } from "../store"
3
4
  import { setAtom } from "./set-atom"
4
5
 
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(attachDevtoolsStates(IMPLICIT.STORE))
188
+ > = createContext({})