From 9b77d65279b2f0d05f9a353f2cfaf875b9105067 Mon Sep 17 00:00:00 2001 From: Jan Andrle Date: Thu, 7 Sep 2023 18:21:51 +0200 Subject: [PATCH] :sparkles: Add ddeSignal type to global scope + TODOs updated --- index.d.ts | 1 - package.json | 2 +- src/signals-lib.js | 4 ++-- src/signals.d.ts | 4 ++++ test/components/todosComponent.js | 2 -- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/index.d.ts b/index.d.ts index 61ee3fc..821a272 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2,7 +2,6 @@ import { Signal } from "./src/signals"; //TODO? declare global { type ddeFires= ( (...a: any[])=> any ) & { events: T }; - type ddeSignal= Signal; } type ElementTagNameMap= HTMLElementTagNameMap & SVGElementTagNameMap & { '#text': Text diff --git a/package.json b/package.json index 1f0b5eb..453bea3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "deka-dom-el", - "version": "0.1.2", + "version": "0.1.3", "description": "A low-code library that simplifies the creation of native DOM elements/components using small wrappers and tweaks.", "author": "Jan Andrle ", "license": "MIT", diff --git a/src/signals-lib.js b/src/signals-lib.js index 4389d59..d3ca9c6 100644 --- a/src/signals-lib.js +++ b/src/signals-lib.js @@ -12,7 +12,7 @@ export function S(value, actions){ const out= create(); watch(()=> out(value())); return out; - //TODO is auto remove if used for args, if external listener needs also S.clear + //TODO for docs: is auto remove if used for args, if external listener needs also S.clear } S.action= function(signal, name, ...a){ const s= signal[mark], { actions }= s; @@ -28,7 +28,7 @@ S.on= function on(signals, listener, options= {}){ if(Array.isArray(signals)) return signals.forEach(s=> on(s, listener, options)); addSignalListener(signals, listener); if(as) as.addEventListener("abort", ()=> removeSignalListener(signals, listener)); - //TODO cleanup when signal removed (also TODO) + //TODO cleanup when signal removed }; S.symbols= { signal: mark, diff --git a/src/signals.d.ts b/src/signals.d.ts index c7b58f2..ac17832 100644 --- a/src/signals.d.ts +++ b/src/signals.d.ts @@ -43,3 +43,7 @@ interface S { } } export const S: S; +declare global { + type ddeSignal= Signal; + type ddeActions= Actions +} diff --git a/test/components/todosComponent.js b/test/components/todosComponent.js index ef5c28c..bc01f6a 100644 --- a/test/components/todosComponent.js +++ b/test/components/todosComponent.js @@ -14,9 +14,7 @@ const className= style.host(todosComponent).css` /** @param {{ todos: string[] }} */ export function todosComponent({ todos= [ "A" ] }= {}){ const todosS= S([], { - /** @param {string} v */ add(v){ this.value.push(S(v)); }, - /** @param {number} i */ remove(i){ this.value.splice(i, 1); }, [S.symbols.onclear](){ S.clear(...this.value); }, });