Skip to content

Enhance setAll / toggleAll actions #793

@fravan

Description

@fravan

Feature Request

Context

I have a signals "map" that has multiple fields like

{ 
  Name: { Value: "stuff", Touched: false }, 
  Email: { Value: "email@email.com", Touched: true },
  ... 
}

I would like to toggle all .Touched signals.
I could rewrite so the touched signals live outside of that, but was wondering the following:

Proposal

As of now, the @setAll and @toggleAll actions work on the prefix of the path of signal.

If we need to @setAll(/.*\.touched/, true), then it is not working.
Writing it like that is actually really not pleasant 🤔 , and maybe that feature request might be a bad idea, but still, I'll leave you to decide!

We could rewrite the setAll / toggleAll to accept either a string, or a regex.
The string would continue as-is. typeof prefix === 'string'
The regex would crush the world. typeof prefix === 'object'

WDYT?

Datastar Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions