Skip to content

Mixing signals and computed-signals disallowed? #10

@mindplay-dk

Description

@mindplay-dk

With the following example:

const value = signal("foo");

const computed = signal($ => value($) + "!!!")();

core($ => console.log(/*"signal:", value(),*/ "computed:", computed($)))();

value("bar");

If I uncomment the bit that prints the signal value, I get an error Mixed rp|rs - and presumably, this is about signals and computed-signals being disallowed in the same context?

Is this "by design"?

With Sinuous (or S.js) and Dipole, you can mix signals and computed-signals. As far as subscriptions go, they both represent a "stream of values", so it's not clear to me why it would be necessary to restrict this.

I am concerned we lose some of the explainability - I like to use a spreadsheet example to explain these concepts, as it's the most well-understood "functional/reactive programming language" there is, and it does not have any restrictions like this.

Imagine you had to refactor a spreadsheet, and something that was a value changes to an expression - if spreadsheets had this limitation, you can imagine how difficult it would be to get it back into a working state.

I'm concerned the same kind of problems will be inherent with this limitation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions