https://github.com/tzachbon/signal-effect
Simple effect method based on the tc39/proposal-signals
https://github.com/tzachbon/signal-effect
ecmascript-proposal effect javascript signal tc39
Last synced: 8 months ago
JSON representation
Simple effect method based on the tc39/proposal-signals
- Host: GitHub
- URL: https://github.com/tzachbon/signal-effect
- Owner: tzachbon
- License: mit
- Created: 2024-04-26T12:01:30.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-12T22:43:10.000Z (10 months ago)
- Last Synced: 2024-11-13T02:18:58.862Z (8 months ago)
- Topics: ecmascript-proposal, effect, javascript, signal, tc39
- Language: TypeScript
- Homepage: https://tzachbon.github.io/signal-effect/
- Size: 251 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Signal Effect
Simple `effect(() => {})` method based on the [tc39/proposal-signals](https://github.com/tc39/proposal-signals)
> Disclaimer: It uses "signal-polyfill" until the proposal is accepted and implemented in the browsers.
## Install
```bash
npm install --save signal-effect signal-polyfill
```## Usage
```js
// polyfill for signal
import { Signal } from 'signal-polyfill';import { effect } from 'signal-effect';
const counter = new Signal.State(0);
effect(() => (element.innerText = counter.get()));
// Simulate external updates to counter...
setInterval(() => counter.set(counter.get() + 1), 1000);
```