tzachbon / signal-effect

Simple effect method based on the tc39/proposal-signals

Home Page:https://tzachbon.github.io/signal-effect/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

signal-effect)

Signal Effect

Simple effect(() => {}) method based on the tc39/proposal-signals

Disclaimer: It uses "signal-polyfill" until the proposal is accepted and implemented in the browsers.

Install

npm install --save signal-effect signal-polyfill

Usage

// 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);

About

Simple effect method based on the tc39/proposal-signals

https://tzachbon.github.io/signal-effect/

License:MIT License


Languages

Language:TypeScript 100.0%