Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): experimental unstable versioned write for limited use case #854

Merged
merged 41 commits into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
76ccf23
feat(core): experimental version object
dai-shi Nov 29, 2021
1c31fa1
refactor
dai-shi Nov 29, 2021
19c45f9
fix test name in ci
dai-shi Nov 29, 2021
6dc6f88
revert test/query
dai-shi Nov 29, 2021
fb6eeed
empty commit
dai-shi Nov 29, 2021
ca7b099
fix workflow file
dai-shi Nov 29, 2021
7aeaf38
remove delay in urql/atomWithQuery
dai-shi Nov 29, 2021
674edc2
merge main
dai-shi Nov 29, 2021
74695d8
fix test
dai-shi Nov 29, 2021
7c77924
tweak query test
dai-shi Nov 29, 2021
5975cef
fix atomWithQuery in urql
dai-shi Nov 30, 2021
cfa7b45
revert again query timing
dai-shi Nov 30, 2021
ef2bbbb
Merge branch 'main' into feat/experimental-version-object
dai-shi Nov 30, 2021
4931b13
Merge branch 'main' into feat/experimental-version-object
dai-shi Nov 30, 2021
58393c9
merge main
dai-shi Dec 1, 2021
9cd13af
wip: non-working commit, trying another path
dai-shi Dec 2, 2021
0364d7f
another approach with provider which requires pure write
dai-shi Dec 2, 2021
8843873
fix logic, add tests, skip tests
dai-shi Dec 5, 2021
bbe485b
merge main
dai-shi Dec 5, 2021
d79ddbb
refactor, simplify
dai-shi Dec 5, 2021
3cdd9bb
wip: refactor
dai-shi Dec 5, 2021
97b0e6d
skip a test
dai-shi Dec 5, 2021
1ac2e5e
skip one more test
dai-shi Dec 5, 2021
88bb80c
skip 16.8.6
dai-shi Dec 5, 2021
8ee52c3
merge main
dai-shi Dec 5, 2021
a7aa1b4
only notify changed atom state
dai-shi Dec 5, 2021
65d6870
remove extra falsy check
dai-shi Dec 5, 2021
877af48
merge main
dai-shi Dec 5, 2021
c6e1e77
fix types
dai-shi Dec 5, 2021
83d3bcc
wip: a workaround for now
dai-shi Dec 6, 2021
18033a9
fix logic, skip one test for now
dai-shi Dec 7, 2021
a4c8188
a minor refactor
dai-shi Dec 7, 2021
da59041
Merge branch 'main' into feat/experimental-version-object
dai-shi Dec 7, 2021
e03606d
Merge branch 'main' into feat/experimental-version-object
dai-shi Dec 8, 2021
6bbad6c
add some notes
dai-shi Dec 8, 2021
570ca47
Merge branch 'main' into feat/experimental-version-object
dai-shi Dec 8, 2021
f2dd752
suspense promise should not throw
dai-shi Dec 10, 2021
ec9eb82
Merge branch 'main' into feat/experimental-version-object
dai-shi Dec 14, 2021
4db89c8
Merge branch 'main' into feat/experimental-version-object
dai-shi Dec 16, 2021
9091d5e
Merge branch 'main' into feat/experimental-version-object
dai-shi Dec 20, 2021
685ae4e
Merge branch 'main' into feat/experimental-version-object
dai-shi Dec 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test-multiple-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
- 18.0.0-beta-149b420f6-20211119
- 0.0.0-experimental-149b420f6-20211119
mode: [withProvider, withoutProvider]
versionObject: [withVersionObject, withoutVersionObject]
testing: [default, alpha]
exclude:
- { react: 16.8.6, testing: alpha }
Expand Down Expand Up @@ -65,9 +66,10 @@ jobs:
run: |
sed -i~ '1s/^/import React from "react";/' tests/*.tsx tests/*/*.tsx
sed -i~ 's/automatic/classic/' babel.config.js
- name: Test ${{ matrix.react }} ${{ matrix.mode }}
- name: Test ${{ matrix.react }} ${{ matrix.mode }} ${{ matrix.versionObject }}
run: |
yarn add -D react@${{ matrix.react }} react-dom@${{ matrix.react }}
yarn test:ci
env:
PROVIDER_LESS_MODE: ${{ matrix.mode == 'withoutProvider' }}
JOTAI_EXPERIMENTAL_VERSION_OBJECT: ${{ matrix.versionObject == 'withVersionObject' }}
12 changes: 10 additions & 2 deletions src/core/contexts.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
import { createContext } from 'react'
import type { Context } from 'react'
import type { Atom, Scope } from './atom'
import { createStore } from './store'
import { VERSION_OBJECT, createStore } from './store'
import type { Store } from './store'

type GetVersion = () => object | undefined

export type ScopeContainer = {
s: Store
v: GetVersion
}

export const createScopeContainer = (
initialValues?: Iterable<readonly [Atom<unknown>, unknown]>
): ScopeContainer => {
const store = createStore(initialValues)
return { s: store }
const getVersion =
typeof process === 'object' &&
process.env.JOTAI_EXPERIMENTAL_VERSION_OBJECT === 'true'
? store[VERSION_OBJECT]
: () => undefined
return { s: store, v: getVersion }
}

type ScopeContext = Context<ScopeContainer>
Expand Down
Loading