Skip to content

Add a store for values that may not be computed yet - #806

Merged
pleek91 merged 1 commit into
mainfrom
data-store
Aug 17, 2026
Merged

Add a store for values that may not be computed yet#806
pleek91 merged 1 commit into
mainfrom
data-store

Conversation

@pleek91

@pleek91 pleek91 commented Jul 31, 2026

Copy link
Copy Markdown
Member

Description

First step of #805. Nothing uses this yet — the store is added on its own so it can be reviewed without the churn of rewiring props at the same time.

A value becomes a promise the moment it is first asked for, rather than only existing once its getter has run. Whoever needs it can await it without knowing when, or by whom, it will be computed:

store.subscribe('user')          // nothing has computed this yet — waits
store.set('user', getUser)       // resolves the promise the subscriber already holds

Alongside the promise, each key records where it has got to — nothing has asked for it, something is waiting on it, its getter is in flight, or how that getter settled. Rendering reads that synchronously instead of waiting a tick, and a getter returning undefined or an Error stays an ordinary value rather than being mistaken for "not ready" or "failed".

A store is also the unit of lifetime. Disposing one rejects everything still outstanding, so anything waiting resumes rather than being suspended for the life of the page — which is what prefetching needs, since most prefetched work is for a navigation that never happens.

@netlify

netlify Bot commented Jul 31, 2026

Copy link
Copy Markdown

Deploy Preview for kitbag-router ready!

Name Link
🔨 Latest commit 3677a9b
🔍 Latest deploy log https://app.netlify.com/projects/kitbag-router/deploys/6a7022601d42ff000847359d
😎 Deploy Preview https://deploy-preview-806--kitbag-router.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pleek91
pleek91 force-pushed the data-store branch 5 times, most recently from e1f5d22 to 23c506b Compare August 3, 2026 02:21
A value becomes a promise the moment it is first asked for, so whoever needs
it can await it without knowing when, or by whom, it will be computed. Values
live in scopes that can be handed on or discarded together.

Nothing uses it yet.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@stackoverfloweth stackoverfloweth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only question is the value of having both a pending state and a running state. I see that something can "watch" for a value by being subscribed and that's meaningful for the store. I also see that when it's running it's actually trying to fulfill a promise that will update those who are watching. Is that basically it?

@pleek91

pleek91 commented Aug 3, 2026

Copy link
Copy Markdown
Member Author

My only question is the value of having both a pending state and a running state. I see that something can "watch" for a value by being subscribed and that's meaningful for the store. I also see that when it's running it's actually trying to fulfill a promise that will update those who are watching. Is that basically it?

A pending state means something requested it but nothing has actually run. So a promise was created and is just waiting for something to actually resolve/reject it.

Vs running means something is actively attempting to resolve/reject that promise. Subtle difference but important for tracking the state of the promise (which we cannot inspect to see if its being resolve or not).

@pleek91 pleek91 mentioned this pull request Aug 3, 2026
@pleek91
pleek91 merged commit 4995724 into main Aug 17, 2026
6 checks passed
@pleek91
pleek91 deleted the data-store branch August 17, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants