reactively
reactively copied to clipboard
Well known Symbols in reactvely
This is a question. Did you explore well known symbols while ideating on Reactively? Symbol.toPrimitive
is relevant to Reactively as a convinence so that you don't have to read with signal.value
everywhere but the getter is called.
import { primitive } from "@reactively/core";
const counter = primitive(0);
const isEven = primitive(() => (counter & 1) == 0);
// ^ no dot value
const prefix = primitive('isEven is');
const evenString = primitive(() => prefix + isEven) // isEven is true;
I haven't looked much at HasReactive
but it might have relevance there too. I was wondering whether you excluded it for performance or other reasons. I suppose there's an elegance to having one interface for all data types too.
For context, I was playing with Symbol.toPrimitive
at https://github.com/kwangure/eventscript to see how reactive builtins might compose just because. There are probably gains to be had integrating with the Reactively
class rather than handling my own reactivity and subscriptions.
This sounds awesome and I've never seen this trick before, the only drawback I can think of is strict equality is more confusing. I've mentioned this to @ryansolid to consider using in SolidJS as well.