proposal-signals icon indicating copy to clipboard operation
proposal-signals copied to clipboard

We need your help to develop Signals!

Open littledan opened this issue 1 year ago • 5 comments

There's a lot that you all can do to help, including:

  • Try out signals within your framework or application
  • Improve the documentation/learning materials for signals
  • Document use cases (whether it's something the API supports well or not)
  • Write more tests, e.g., by porting them from other signal implementations #70
  • Port other signal implementations to this API
  • Write benchmarks for signals, both synthetic and real-world application ones #71
  • File issues on polyfill bugs, your design thoughts, etc.
  • Development reactive data structures/state management abstractions on top of signals
  • Implement signals natively in a JS engine (behind a flag/in a PR, not shipped!)

littledan avatar Apr 01 '24 04:04 littledan

I'm making a utility library here: https://github.com/NullVoxPopuli/signal-utils

The implementations and tests are going to be ports from other ecosystems :tada: I can also use this repo's tests to see how changes to the polyfill over time affect things!

Current structures / utils:

  • SignalArray
  • SignalObject
  • SignalMap
  • SignalWeakMap
  • SignalSet
  • SignalWeakSet
  • SignalAsyncData / load -- provides reactive signal-states for the phases and results of a promise
  • signalFunction -- reactive automatic and lazy async function invocation
  • localCopy -- fork remote state
  • @signal turn any property on a class into a transparent Signal.State
  • @cached turn any getter on a class into a transparent Signal.Computed
  • @localCopy alternate way to fork remote state in classes -- idk what's better

NullVoxPopuli avatar Apr 01 '24 15:04 NullVoxPopuli

Cool, I'll try it out here soon: https://github.com/quantuminformation/vanillajs-patterns

quantuminformation avatar Apr 10 '24 14:04 quantuminformation

I'm failing to get the example code shown in the readme to work (section: "Using signals"). This is the counter/isEven/parity example, and I am using the effect.js implementation shown there, too (section "Creating a simple effect"). I'm using node 21.7.3.

The problem is that the effect() callback is never run (except for the initial time). What am I doing wrong?

Note: I added a console.log() to the setInterval callback to make sure it is being called and, yes, it is, but no corresponding output from the effect() callback.

Note: I get the same behavior when using the signal-polyfill package from npm, or when directly using the polyfill built from this repository's packages/signal-polyfill subdirectory.

PS very excited about this, and looking forward to getting it to work!


UPDATE: I got this to work after changing the given example code for effect.js:

  1. changed initialization of needsEnqueue from false to true
  2. changed queueMicrotask.enqueue(...) to queueMicrotask(...)

Would it be possible to update the readme example?

ed-puckett avatar Apr 16 '24 07:04 ed-puckett

Would it be possible to update the readme example?

of course! would you like to submit a PR? We also have a working example of the microtaskqueue effect here: https://github.com/proposal-signals/signal-utils/blob/main/src/subtle/microtask-effect.ts

NullVoxPopuli avatar Apr 20 '24 17:04 NullVoxPopuli

I have developed a tsx application framework called airx that fully embraces Signal. It is designed for learning purposes. Here is a code snippet:

const count = new Signal.State(0);

function Counter() {
  const handleClick = () => {
    count.set(count.get() + 1);
  };

  return () => (
    <button onClick={handleClick}>
      count is {count.get()}
    </button>
  );
}

Quick demo: https://codesandbox.io/p/devbox/github/airxjs/vite-template/tree/signal/?file=%2Fsrc%2FApp.tsx%3A7%2C1

yinxulai avatar May 20 '24 08:05 yinxulai