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

Improve writing of store setters with range and multiple indices #1110

Merged
merged 2 commits into from
Mar 7, 2025

Conversation

edemaine
Copy link
Contributor

@edemaine edemaine commented Mar 6, 2025

  • I have read the Contribution guide
  • This PR references an issue (except for typos, broken links, or other minor problems)

Description

Stores have some magic syntax for modifying multiple elements at once: arrays and {from, to, [step]} objects. Previously we called both of them "ranges", but only the latter is ranges. Now the category is "modifying multiple elements", and only one is called a range. I also noticed that the array syntax works for object properties too, so I documented that. Also added a bunch of examples, and added explicit equivalent code to explain exactly what they're doing. Also mentioned the key difference, which is batching.

I didn't actually know these features, but did some basic testing to understand how they work. (The answer is: very generally.)

Related issues & labels

This PR was motivated by zulu's Discord message:

can someone make it clearer that

this in fact mean update at index 1 and 3 and not the range of 1..3

https://docs.solidjs.com/concepts/stores#range-specification

[1,3] is not really a range per say

if the example was [3,10,4] it would have prevented me from making the wrong assumptions

setStore("users", [1, 3], "loggedIn", false)

Sorry, something went wrong.

Copy link

stackblitz bot commented Mar 6, 2025

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

netlify bot commented Mar 6, 2025

Deploy Preview for solid-docs ready!

Name Link
🔨 Latest commit 103533d
🔍 Latest deploy log https://app.netlify.com/sites/solid-docs/deploys/67ca347a023de3000873fd16
😎 Deploy Preview https://deploy-preview-1110--solid-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@LadyBluenotes LadyBluenotes merged commit c816cb3 into main Mar 7, 2025
6 of 8 checks passed
@LadyBluenotes LadyBluenotes deleted the multi-index branch March 7, 2025 05:06
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.

None yet

2 participants