Skip to content

Set Signal Function #223

@Myrdden

Description

@Myrdden

Hello, would it be possible to have signal setters take a function, like setState and memo do? I.E.

const [getSignal, setSignal] = createSignal([]);
const push = (val) => setSignal(prev => [...prev, val]);

or something similar?

My gut is worried because it feels to me like doing setSignal([...getSignal(), val]) would open up the potential for some infinite loops, and wrapping getSignal in untracked is a lot of typing... Also, I suppose as most of the other functions can do that, especially setState, it would seem to fit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions