Skip to content

Support temporary latest field for createAsync and createAsyncStore#463

Merged
ryansolid merged 2 commits intosolidjs:mainfrom
elite174:feat/latest
Aug 6, 2024
Merged

Support temporary latest field for createAsync and createAsyncStore#463
ryansolid merged 2 commits intosolidjs:mainfrom
elite174:feat/latest

Conversation

@elite174
Copy link
Copy Markdown
Contributor

This PR adds support for latest field for createAsync and createAsyncStore for compatibility with createResource.

MOTIVATION

At the moment createAsync and createAsyncStore are just wrappers for createResource. createResource provides the mechanism to avoid triggering Suspense, which is quite useful in some cases.

In order to improve adoption of createAsync and createAsyncStore it would be useful to provide this mechanism also for these primitives.

In the future major release of solid support of the latest field (and createResource) will be dropped in favor of createAsync and createAsyncStore. .latest could be replaced with latest(...) helper (TBD) or could be dropped at all. In both cases the migration will be simple:

  • Replaced with latest(...) helper: data.latest => latest(data)
  • Dropped support of .latest field: data.latest => data

At the moment lack of .latest support for createAsync and createAsyncStore prevents people from wide adoption of these primitives. Moreover, people start invent some hacks like this which consume much more memory.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jul 23, 2024

⚠️ No Changeset found

Latest commit: 6531a76

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ryansolid
Copy link
Copy Markdown
Member

Yeah.. I was hoping to avoid this until we had a better idea of what the future API would look like. But it seems we're here. Having something like .latest is relatively low risk as you said as it isn't transitive and it doesn't cause poor patterns like .state or .error or .loading can unintentionally. So my gut is we can move with this and the migration cost will be relatively minor. It will still be something, but it is localized mostly.

@elite174
Copy link
Copy Markdown
Contributor Author

Could someone merge this thing then?

@elite174
Copy link
Copy Markdown
Contributor Author

@ryansolid Could someone merge this PR please, if you agree?

@ryansolid
Copy link
Copy Markdown
Member

I'm not ignoring this. I am just being a little slow. We need to be careful and I'm actively looking at stuff right now that I figured a few more days wouldn't make a huge difference. If I don't get to where I want by the end of the week we can go ahead.

@ryansolid ryansolid merged commit f84b81f into solidjs:main Aug 6, 2024
@ryansolid
Copy link
Copy Markdown
Member

I write about my thinking here: https://dev.to/this-is-learning/async-derivations-in-reactivity-ec5

@elite174 elite174 deleted the feat/latest branch August 7, 2024 08:38
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