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

FEAT: maxLength/minLength options on useCollection #206

Open
HugoPerard opened this issue Nov 17, 2023 · 0 comments
Open

FEAT: maxLength/minLength options on useCollection #206

HugoPerard opened this issue Nov 17, 2023 · 0 comments
Labels
enhancement New feature or request feature good first issue Good for newcomers v2

Comments

@HugoPerard
Copy link
Member

Is your feature request related to a problem? Please describe.
This feature can avoid to manually do some check if we want to build a collection with some length condition, for example with at least one element, or/and with 10 elements max

const collection = useCollection("collection");
...
{collection.length > 1 && <button>Remove item</button>
...
{collection.length < 10 && <button>Add item<button>}

Describe the solution you'd like
I'm thinking about two new states on the collection, with no name defined, that should transform previous to this :

const collection = useCollection("collection", { maxLength: 10, minLength: 1 });
...
{collection.canRemove && <button>Remove item</button>}
...
{collection.canAdd && <button>Add item</button>}
@HugoPerard HugoPerard added enhancement New feature or request good first issue Good for newcomers feature v2 labels Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature good first issue Good for newcomers v2
Projects
None yet
Development

No branches or pull requests

1 participant