solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.13k stars 143 forks source link

Support temporary `latest` field for `createAsync` and `createAsyncStore` #463

Closed elite174 closed 1 month ago

elite174 commented 1 month ago

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:

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[bot] commented 1 month ago

⚠️ No Changeset found

Latest commit: 6531a764403c1048be9f709a790551106f4c0cd5

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 commented 1 month ago

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 commented 1 month ago

Could someone merge this thing then?

elite174 commented 1 month ago

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

ryansolid commented 1 month ago

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 commented 1 month ago

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