Skip to content

Support Composability on Runes #12917

Closed as not planned
Closed as not planned
@mrh1997

Description

@mrh1997

Describe the problem

In #9651 there was already a discussion on building "Higher Order Stores with Runes" which resulted in the recommendation of passing functions that return runes. But as already mentioned in this recommendation this solution is only unidirectional (no binding possible).

You could implement this bidirectional via creating an wrapper object with a getter and a setter. But passing a parameter to this composable ("double") is very ugly:

const comp = double({get value() { return count; }, set value(v) { count = v; }});

Especially when working with nested composables (a(b(c))) this approach gets totally unreadable.

Describe the proposed solution

It would be great if there would be a boxing rune that does the wrapping for me:

const comp = double($wrap(count));

Furthermore I would like to see a recommendation/best practice from sveltejs which name to use for the attribute so that all composables will use the same resolving mechanism. In my proposal this is .value but fromStore() uses .current. This should be standardized to make composables composable...

Importance

would make my life easier

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions