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

Prepare to implement tracked storage, RFC#669 #20761

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions packages/@glimmer/tracking/primitives/storage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* https://rfcs.emberjs.com/id/0669-tracked-storage-primitive
*
* See, in particular:
* https://rfcs.emberjs.com/id/0669-tracked-storage-primitive#re-implementing-tracked-with-storage
*
* This was an earlier iteration of "Cells" from starbeam.
*
* Ultimately, these functions could (and maybe should)
* be re-exports from Glimmer and/or Starbeam
*/

export function createStorage<T>(
initialValue?: T,

Check failure on line 14 in packages/@glimmer/tracking/primitives/storage.ts

View workflow job for this annotation

GitHub Actions / Type Checking (current version)

'initialValue' is declared but its value is never read.

Check failure on line 14 in packages/@glimmer/tracking/primitives/storage.ts

View workflow job for this annotation

GitHub Actions / Linting

'initialValue' is defined but never used. Allowed unused args must match /^_/u
isEqual?: (oldValue: T, newValue: T) => boolean

Check failure on line 15 in packages/@glimmer/tracking/primitives/storage.ts

View workflow job for this annotation

GitHub Actions / Type Checking (current version)

'isEqual' is declared but its value is never read.

Check failure on line 15 in packages/@glimmer/tracking/primitives/storage.ts

View workflow job for this annotation

GitHub Actions / Linting

'isEqual' is defined but never used. Allowed unused args must match /^_/u
): Storage<T> {

Check failure on line 16 in packages/@glimmer/tracking/primitives/storage.ts

View workflow job for this annotation

GitHub Actions / Type Checking (current version)

Type 'Storage' is not generic.
throw new Error('Not Implemented');
}

/**
* This function receives a tracked storage instance, and returns the value it contains, consuming it so that it entangles with any currently active autotracking contexts.
*/
export function getValue<T>(storage: Storage<T>): T {

Check failure on line 23 in packages/@glimmer/tracking/primitives/storage.ts

View workflow job for this annotation

GitHub Actions / Type Checking (current version)

'storage' is declared but its value is never read.

Check failure on line 23 in packages/@glimmer/tracking/primitives/storage.ts

View workflow job for this annotation

GitHub Actions / Type Checking (current version)

Type 'Storage' is not generic.

Check failure on line 23 in packages/@glimmer/tracking/primitives/storage.ts

View workflow job for this annotation

GitHub Actions / Linting

'storage' is defined but never used. Allowed unused args must match /^_/u
throw new Error('Not Implemented');
}

/**
* This function receives a tracked storage instance and a value, and sets the value of the tracked storage to the passed value if it is not equal to the previous value. If the value is set, it will dirty the storage, causing any tracked computations which consumed the stored value to recompute. If the value was not changed, then it does not set the value or dirty it.
*/
export function setValue<T>(storage: Storage<T>, value: T): void {

Check failure on line 30 in packages/@glimmer/tracking/primitives/storage.ts

View workflow job for this annotation

GitHub Actions / Type Checking (current version)

'storage' is declared but its value is never read.

Check failure on line 30 in packages/@glimmer/tracking/primitives/storage.ts

View workflow job for this annotation

GitHub Actions / Type Checking (current version)

Type 'Storage' is not generic.

Check failure on line 30 in packages/@glimmer/tracking/primitives/storage.ts

View workflow job for this annotation

GitHub Actions / Type Checking (current version)

'value' is declared but its value is never read.

Check failure on line 30 in packages/@glimmer/tracking/primitives/storage.ts

View workflow job for this annotation

GitHub Actions / Linting

'storage' is defined but never used. Allowed unused args must match /^_/u

Check failure on line 30 in packages/@glimmer/tracking/primitives/storage.ts

View workflow job for this annotation

GitHub Actions / Linting

'value' is defined but never used. Allowed unused args must match /^_/u
throw new Error('Not Implemented');
}
Loading