Add selectors
Using createSelector is good for a single values. I found that there are a lot of use cases for array selectors. I have been using this on a few projects and I think it would be a good addition to the library.
const list: string[] = ["apple", "pear", "orange"]
const [selectedItems] = createSignal<string[]>(["apple"])
const isSelected = createArraySelector(selectedItems)
<For each={list}>
{(item) => <li classList={{ active: isSelected(item) }}>{item}</li>}
</For>
Extending with a comparator function (instead of b.includes(a)) to support objects could be possible, but I decided to keep it simple. At that point it might be better to just create a custom selector directly.
⚠️ No Changeset found
Latest commit: 0e5a5bdee91665b4c43448c57d22e04248d4c90d
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