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

Derived Stores #40

Open
wants to merge 95 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
d3be221
feat!: initial work on adding derived signals
crutchcorn Feb 5, 2024
5830fca
chore: add tests to derived state
crutchcorn Feb 5, 2024
ae74fa5
fix: add cleanup edgecase
crutchcorn Feb 5, 2024
605b520
fix: edgecase where using derived and store for base
crutchcorn Feb 5, 2024
9d4deb7
docs: update docs link
crutchcorn Feb 6, 2024
12d40a6
chore: refactor derived class
crutchcorn Feb 6, 2024
368db9d
chore: further refactors
crutchcorn Feb 6, 2024
759040d
chore: refactor work to make things a bit cleaner
crutchcorn Feb 6, 2024
d79b473
chore: minor renaming and cleanup
crutchcorn Feb 7, 2024
5700cc3
chore: add initial benchmarks
crutchcorn Feb 7, 2024
0f7c648
chore: add Angular
crutchcorn Feb 7, 2024
f0ec935
chore: update benchmark package versions
crutchcorn Feb 7, 2024
790303c
chore: fix ci
crutchcorn Feb 7, 2024
5a069c7
chore: move to proper derived store
crutchcorn Feb 9, 2024
157413f
fix: avoid issues with what signal is being written
crutchcorn Feb 9, 2024
192829c
chore: ignore benchmark file in test coverage
crutchcorn Feb 9, 2024
f4dc9da
chore: rename TSX to TS
crutchcorn Feb 9, 2024
b7987e8
feat: add Effect
crutchcorn Feb 9, 2024
aa447aa
Merge branch 'main' into derived-diamond-problem
lachlancollins Feb 17, 2024
87dd588
Fix eslint, sherif, and knip
lachlancollins Feb 17, 2024
de55814
chore: migrate from forEach to for of loop
crutchcorn Feb 26, 2024
2bb46e3
Merge branch 'main' into derived-diamond-problem
crutchcorn Aug 12, 2024
fa65a7e
ci: apply automated fixes
autofix-ci[bot] Aug 12, 2024
357a301
improve Vue performance (#122)
ZainW Sep 29, 2024
228db0e
feat: add lazyness to derived (#109)
crutchcorn Nov 25, 2024
925ecae
Merge branch 'main' into derived-diamond-problem
crutchcorn Nov 25, 2024
81ef72c
chore: migrate to options object over positional arguments
crutchcorn Nov 25, 2024
eac78fa
ci: apply automated fixes
autofix-ci[bot] Nov 25, 2024
a7e9cbe
chore: fix sherif
crutchcorn Nov 25, 2024
62c3664
Merge branch 'main' into derived-diamond-problem
crutchcorn Nov 25, 2024
bd900f7
docs: add autogenerated docs for effect and derived
crutchcorn Nov 25, 2024
3db6e6f
Merge branch 'main' into derived-diamond-problem
crutchcorn Nov 25, 2024
49e47ea
Merge branch 'main' into derived-diamond-problem
crutchcorn Nov 25, 2024
8105722
Merge branch 'main' into derived-diamond-problem
crutchcorn Nov 25, 2024
b952bce
chore: migrate derived and effect to have cleanup and mount as distin…
crutchcorn Nov 25, 2024
9958187
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 25, 2024
b53b821
feat: add previous and current value to the store
crutchcorn Nov 25, 2024
a46d778
feat: add ability to track previous and new values of deps
crutchcorn Nov 25, 2024
cd7bb0d
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 25, 2024
0fe4628
chore: fix build
crutchcorn Nov 25, 2024
cc48436
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 25, 2024
709f04b
feat: add ability to get previous value from derived fn
crutchcorn Nov 27, 2024
f8c9839
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 27, 2024
c3b3f94
feat: add proper typings to derived state
crutchcorn Nov 27, 2024
cef42eb
Merge branch 'derived-diamond-problem' of https://github.com/TanStack…
crutchcorn Nov 27, 2024
24a771b
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 27, 2024
ec4fcc1
chore: fix potentially faulty TState inferencing
crutchcorn Nov 27, 2024
555b7bb
Merge branch 'derived-diamond-problem' of https://github.com/TanStack…
crutchcorn Nov 27, 2024
15ce0d4
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 27, 2024
b1fa3ad
chore: fix usage for TypeScript 4.9
crutchcorn Nov 29, 2024
ab0889d
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 29, 2024
4be2a82
chore: fix knip
crutchcorn Nov 29, 2024
e96a781
Merge branch 'derived-diamond-problem' of https://github.com/TanStack…
crutchcorn Nov 29, 2024
bf39f70
chore: more work to support TS5
crutchcorn Nov 29, 2024
1e7fec0
chore: fix usage of import and require type
crutchcorn Nov 29, 2024
df0646d
chore!: drop TypeScript 4.9 support
crutchcorn Nov 29, 2024
7b0bdd2
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 29, 2024
d751b2d
fix: prevState now works as intended
crutchcorn Nov 29, 2024
e8ff103
chore!: remove store.batch, add in temporary scheduler, skip intentio…
crutchcorn Nov 29, 2024
5f11306
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 29, 2024
8fb38a8
chore: add working unregister from graph
crutchcorn Nov 29, 2024
ee55538
chore: hooman attempt
crutchcorn Nov 29, 2024
0be5257
chore: cursor attempt
crutchcorn Nov 29, 2024
7a41b27
chore: code cleanup and add back batch tests
crutchcorn Nov 29, 2024
dbbf664
chore: fix listener recieving old values
crutchcorn Nov 29, 2024
2b95688
chore: fix laziness
crutchcorn Nov 29, 2024
9661c17
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 29, 2024
acf03d7
chore!: fix timings and temporarily(?) remove lazy prop
crutchcorn Nov 30, 2024
7e9752f
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 30, 2024
13c472f
chore: migrate useStore in React to support Derived values stores as …
crutchcorn Nov 30, 2024
8c0e587
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 30, 2024
782e772
chore: fix CI tests
crutchcorn Nov 30, 2024
5d2e67f
chore: add Angular store Derived support
crutchcorn Nov 30, 2024
6e5156d
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 30, 2024
2baec1f
chore: fix issues with Solid store tests
crutchcorn Nov 30, 2024
ac58a5f
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 30, 2024
2c4129f
chore: fix useStore from Vue
crutchcorn Nov 30, 2024
861e8df
Merge branch 'derived-diamond-problem' of https://github.com/TanStack…
crutchcorn Nov 30, 2024
59ab2df
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 30, 2024
9a5d485
chore: svelte works with useStore now
crutchcorn Nov 30, 2024
697d15e
Merge branch 'derived-diamond-problem' of https://github.com/TanStack…
crutchcorn Nov 30, 2024
46e63ef
ci: apply automated fixes and generate docs
autofix-ci[bot] Nov 30, 2024
7dc64d5
chore: add demo of useStore working as-intended
crutchcorn Nov 30, 2024
34ae6b0
Merge branch 'derived-diamond-problem' of https://github.com/TanStack…
crutchcorn Nov 30, 2024
f8c01f6
chore: fix CI
crutchcorn Nov 30, 2024
e9c449d
fix: issues with unmounting and remounting derived values
crutchcorn Dec 1, 2024
ab4c1f3
ci: apply automated fixes and generate docs
autofix-ci[bot] Dec 1, 2024
2e0bfd3
chore: add failing tests
crutchcorn Dec 1, 2024
634cbf2
fix: issues with out-of-order mounting should be fixed
crutchcorn Dec 1, 2024
e16ced5
Merge branch 'derived-diamond-problem' of https://github.com/TanStack…
crutchcorn Dec 1, 2024
4ec258b
ci: apply automated fixes and generate docs
autofix-ci[bot] Dec 1, 2024
ce6f794
chore: add tests
crutchcorn Dec 1, 2024
38558db
ci: apply automated fixes and generate docs
autofix-ci[bot] Dec 1, 2024
29af493
chore: add another failing test
crutchcorn Dec 1, 2024
cc45169
ci: apply automated fixes and generate docs
autofix-ci[bot] Dec 1, 2024
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
12 changes: 12 additions & 0 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,22 @@
"label": "Classes / Store",
"to": "reference/classes/store"
},
{
"label": "Classes / Derived",
"to": "reference/classes/derived"
},
{
"label": "Classes / Effect",
"to": "reference/classes/effect"
},
{
"label": "Interfaces / StoreOptions",
"to": "reference/interfaces/storeoptions"
}
{
"label": "Interfaces / DerivedOptions",
"to": "reference/interfaces/derivedoptions"
}
],
"frameworks": [
{
Expand Down
55 changes: 43 additions & 12 deletions docs/framework/angular/reference/functions/injectstore.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,64 @@ title: injectStore

# Function: injectStore()

## injectStore(store, selector, options)

```ts
function injectStore<TState, TSelected, TUpdater>(
function injectStore<TState, TSelected>(
store,
selector,
options): Signal<TSelected>
selector?,
options?): Signal<TSelected>
```

## Type Parameters
### Type Parameters

• **TState**

• **TSelected** = `NoInfer`\<`TState`\>

• **TUpdater** *extends* `AnyUpdater` = `AnyUpdater`
### Parameters

• **store**: `Store`\<`TState`, `any`\>

• **selector?**

• **options?**: `CreateSignalOptions`\<`TSelected`\> & `object`

### Returns

`Signal`\<`TSelected`\>

### Defined in

[index.ts:19](https://github.com/TanStack/store/blob/main/packages/angular-store/src/index.ts#L19)

## injectStore(store, selector, options)

```ts
function injectStore<TState, TSelected>(
store,
selector?,
options?): Signal<TSelected>
```

### Type Parameters

• **TState**

• **TSelected** = `NoInfer`\<`TState`\>

## Parameters
### Parameters

• **store**: `Store`\<`TState`, `TUpdater`\>
• **store**: `Derived`\<`TState`, `any`\>

• **selector** = `...`
• **selector?**

• **options**: `CreateSignalOptions`\<`TSelected`\> & `object` = `...`
• **options?**: `CreateSignalOptions`\<`TSelected`\> & `object`

## Returns
### Returns

`Signal`\<`TSelected`\>

## Defined in
### Defined in

[index.ts:17](https://github.com/TanStack/store/blob/main/packages/angular-store/src/index.ts#L17)
[index.ts:24](https://github.com/TanStack/store/blob/main/packages/angular-store/src/index.ts#L24)
2 changes: 1 addition & 1 deletion docs/framework/react/reference/functions/shallow.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ function shallow<T>(objA, objB): boolean

## Defined in

[index.ts:30](https://github.com/TanStack/store/blob/main/packages/react-store/src/index.ts#L30)
[index.ts:34](https://github.com/TanStack/store/blob/main/packages/react-store/src/index.ts#L34)
44 changes: 35 additions & 9 deletions docs/framework/react/reference/functions/usestore.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,54 @@ title: useStore

# Function: useStore()

## useStore(store, selector)

```ts
function useStore<TState, TSelected, TUpdater>(store, selector): TSelected
function useStore<TState, TSelected>(store, selector?): TSelected
```

## Type Parameters
### Type Parameters

• **TState**

• **TSelected** = `NoInfer`\<`TState`\>

• **TUpdater** *extends* `AnyUpdater` = `AnyUpdater`

## Parameters
### Parameters

• **store**: `Store`\<`TState`, `TUpdater`\>
• **store**: `Store`\<`TState`, `any`\>

• **selector** = `...`
• **selector?**

## Returns
### Returns

`TSelected`

## Defined in
### Defined in

[index.ts:11](https://github.com/TanStack/store/blob/main/packages/react-store/src/index.ts#L11)

## useStore(store, selector)

```ts
function useStore<TState, TSelected>(store, selector?): TSelected
```

### Type Parameters

• **TState**

• **TSelected** = `NoInfer`\<`TState`\>

### Parameters

• **store**: `Derived`\<`TState`, `any`\>

• **selector?**

### Returns

`TSelected`

### Defined in

[index.ts:15](https://github.com/TanStack/store/blob/main/packages/react-store/src/index.ts#L15)
44 changes: 35 additions & 9 deletions docs/framework/solid/reference/functions/usestore.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,54 @@ title: useStore

# Function: useStore()

## useStore(store, selector)

```ts
function useStore<TState, TSelected, TUpdater>(store, selector): Accessor<TSelected>
function useStore<TState, TSelected>(store, selector?): Accessor<TSelected>
```

## Type Parameters
### Type Parameters

• **TState**

• **TSelected** = `NoInfer`\<`TState`\>

• **TUpdater** *extends* `AnyUpdater` = `AnyUpdater`

## Parameters
### Parameters

• **store**: `Store`\<`TState`, `TUpdater`\>
• **store**: `Store`\<`TState`, `any`\>

• **selector** = `...`
• **selector?**

## Returns
### Returns

`Accessor`\<`TSelected`\>

## Defined in
### Defined in

[index.tsx:13](https://github.com/TanStack/store/blob/main/packages/solid-store/src/index.tsx#L13)

## useStore(store, selector)

```ts
function useStore<TState, TSelected>(store, selector?): Accessor<TSelected>
```

### Type Parameters

• **TState**

• **TSelected** = `NoInfer`\<`TState`\>

### Parameters

• **store**: `Derived`\<`TState`, `any`\>

• **selector?**

### Returns

`Accessor`\<`TSelected`\>

### Defined in

[index.tsx:17](https://github.com/TanStack/store/blob/main/packages/solid-store/src/index.tsx#L17)
2 changes: 1 addition & 1 deletion docs/framework/svelte/reference/functions/shallow.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ function shallow<T>(objA, objB): boolean

## Defined in

[index.svelte.ts:39](https://github.com/TanStack/store/blob/main/packages/svelte-store/src/index.svelte.ts#L39)
[index.svelte.ts:43](https://github.com/TanStack/store/blob/main/packages/svelte-store/src/index.svelte.ts#L43)
56 changes: 41 additions & 15 deletions docs/framework/svelte/reference/functions/usestore.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,66 @@ title: useStore

# Function: useStore()

## useStore(store, selector)

```ts
function useStore<TState, TSelected, TUpdater>(store, selector): object
function useStore<TState, TSelected>(store, selector?): object
```

## Type Parameters
### Type Parameters

• **TState**

• **TSelected** = `NoInfer`\<`TState`\>

• **TUpdater** *extends* `AnyUpdater` = `AnyUpdater`

## Parameters
### Parameters

• **store**: `Store`\<`TState`, `TUpdater`\>
• **store**: `Store`\<`TState`, `any`\>

• **selector** = `...`
• **selector?**

## Returns
### Returns

`object`

### current
#### current

```ts
readonly current: TSelected;
```

#### Get Signature
### Defined in

[index.svelte.ts:10](https://github.com/TanStack/store/blob/main/packages/svelte-store/src/index.svelte.ts#L10)

## useStore(store, selector)

```ts
get current(): TSelected
function useStore<TState, TSelected>(store, selector?): object
```

##### Returns
### Type Parameters

`TSelected`
• **TState**

## Defined in
• **TSelected** = `NoInfer`\<`TState`\>

[index.svelte.ts:10](https://github.com/TanStack/store/blob/main/packages/svelte-store/src/index.svelte.ts#L10)
### Parameters

• **store**: `Derived`\<`TState`, `any`\>

• **selector?**

### Returns

`object`

#### current

```ts
readonly current: TSelected;
```

### Defined in

[index.svelte.ts:14](https://github.com/TanStack/store/blob/main/packages/svelte-store/src/index.svelte.ts#L14)
2 changes: 1 addition & 1 deletion docs/framework/vue/reference/functions/shallow.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ function shallow<T>(objA, objB): boolean

## Defined in

[index.ts:43](https://github.com/TanStack/store/blob/main/packages/vue-store/src/index.ts#L43)
[index.ts:47](https://github.com/TanStack/store/blob/main/packages/vue-store/src/index.ts#L47)
44 changes: 35 additions & 9 deletions docs/framework/vue/reference/functions/usestore.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,54 @@ title: useStore

# Function: useStore()

## useStore(store, selector)

```ts
function useStore<TState, TSelected, TUpdater>(store, selector): Readonly<Ref<TSelected>>
function useStore<TState, TSelected>(store, selector?): Readonly<Ref<TSelected>>
```

## Type Parameters
### Type Parameters

• **TState**

• **TSelected** = `NoInfer`\<`TState`\>

• **TUpdater** *extends* `AnyUpdater` = `AnyUpdater`

## Parameters
### Parameters

• **store**: `Store`\<`TState`, `TUpdater`\>
• **store**: `Store`\<`TState`, `any`\>

• **selector** = `...`
• **selector?**

## Returns
### Returns

`Readonly`\<`Ref`\<`TSelected`\>\>

## Defined in
### Defined in

[index.ts:12](https://github.com/TanStack/store/blob/main/packages/vue-store/src/index.ts#L12)

## useStore(store, selector)

```ts
function useStore<TState, TSelected>(store, selector?): Readonly<Ref<TSelected>>
```

### Type Parameters

• **TState**

• **TSelected** = `NoInfer`\<`TState`\>

### Parameters

• **store**: `Derived`\<`TState`, `any`\>

• **selector?**

### Returns

`Readonly`\<`Ref`\<`TSelected`\>\>

### Defined in

[index.ts:16](https://github.com/TanStack/store/blob/main/packages/vue-store/src/index.ts#L16)
Loading
Loading