Skip to content

Commit

Permalink
- move README to website
Browse files Browse the repository at this point in the history
- convert directory to single file
  • Loading branch information
David Maskasky committed Oct 6, 2023
1 parent 1d5e528 commit 980f7bd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 151 deletions.
2 changes: 1 addition & 1 deletion __tests__/mutableAtom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { act, render, renderHook, waitFor } from '@testing-library/react'
import { atom, getDefaultStore, useAtom, useAtomValue, useSetAtom } from 'jotai'
import assert from 'minimalistic-assert'
import { mutableAtom } from '../src/mutableAtom'
import type { ProxyState } from '../src/mutableAtom/types'
import type { ProxyState } from '../src/mutableAtom'

it('should be defined on initial render', async () => {
expect.assertions(1)
Expand Down
31 changes: 24 additions & 7 deletions src/mutableAtom/index.ts → src/mutableAtom.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { atom } from 'jotai/vanilla'
import { proxy, snapshot, subscribe } from 'valtio/vanilla'
import type {
Action,
ActionWithPayload,
Options,
ProxyState,
Store,
} from './types'

type Wrapped<T> = { value: T }

type ProxyFn<T> = (obj: Wrapped<T>) => Wrapped<T>

type Options<T> = {
proxyFn?: ProxyFn<T>
}

export function mutableAtom<Value>(
initialValue: Value,
Expand Down Expand Up @@ -102,3 +103,19 @@ export function mutableAtom<Value>(
const defaultOptions = {
proxyFn: proxy,
}

type Store<Value> = {
proxyState: ProxyState<Value>
getValue: () => Value
setValue: (value: Value) => void
}

export type ProxyState<Value> = { value: Value }

type Action<Type extends string> = {
type: Type
}

type ActionWithPayload<Type extends string, Payload> = Action<Type> & {
payload: Payload
}
120 changes: 0 additions & 120 deletions src/mutableAtom/README.md

This file was deleted.

23 changes: 0 additions & 23 deletions src/mutableAtom/types.ts

This file was deleted.

0 comments on commit 980f7bd

Please sign in to comment.