We need your help to develop Signals!
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!)
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
@signalturn any property on a class into a transparentSignal.State@cachedturn any getter on a class into a transparentSignal.Computed@localCopyalternate way to fork remote state in classes -- idk what's better
Cool, I'll try it out here soon: https://github.com/quantuminformation/vanillajs-patterns
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:
- changed initialization of needsEnqueue from false to true
- changed queueMicrotask.enqueue(...) to queueMicrotask(...)
Would it be possible to update the readme example?
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
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