Skip to content

Reactive/Store-like primitive #4

Open
@marvinhagemeister

Description

@marvinhagemeister
// Turns properties into signals
const r = reactive({ foo: 123, bar: "hehe" });

console.log(r.foo.value);

Open question: Should conversion be deep or shallow?

Pros

  • Easy to make an existing object reactive

Cons

  • tbd

Update with assign()-syntax

// Update a Reactive with assign()-like syntax:
const r = reactive({ name: "Alice" });
update(r, { name: "Bob" });

// property 'age' does not exist in type '{ name?: string }'
update(r, { age: 42 });

// '2' has no properties in common with '{ name?: string }'
update(r, 2);

console.log(r.name.value); // "Bob"

Pros

  • Good for Redux users?

Cons

  • Ambiguity for collections/arrays: Should we update or concat?
  • Is this needed for an MVP or could this be added in users themselves? What's the use case?
  • Risks forking update logic

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