npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lytjs/core-signal

v6.9.6

Published

Lyt.js Core - Signal rendering mode only

Readme

@lytjs/core-signal

LytJS 核心应用 API(Signal 渲染模式),适合细粒度响应式场景

安装

npm install @lytjs/core-signal

与 @lytjs/core 的区别

| 特性 | @lytjs/core-signal | @lytjs/core | | -------- | ------------------ | --------------------- | | 渲染模式 | 仅 Signal | VNode + Signal 双模式 | | 包体积 | 更小 | 完整功能 | | 适用场景 | 细粒度响应式应用 | 需要双模式切换的应用 | | 性能特点 | 细粒度更新 | 灵活选择 |

核心 API

createApp

创建 Signal 模式应用实例:

import { createApp, defineComponent, signal } from '@lytjs/core-signal';

const App = defineComponent({
  template: `
    <div>
      <p>Count: {{ count() }}</p>
      <button @click="increment">Increment</button>
    </div>
  `,
  setup() {
    const count = signal(0);

    const increment = () => {
      count.set(count() + 1);
    };

    return { count, increment };
  },
});

createApp(App).mount('#app');

Signal API

import { signal, computed, writableComputedSignal } from '@lytjs/core-signal';

// 创建 Signal
const count = signal(0);

// 读取值
console.log(count()); // 0

// 设置值
count.set(10);

// 通过 updater 更新
count.update((v) => v + 1);

// 计算 Signal
const doubled = computed(() => count() * 2);

// 可写计算 Signal
const fullName = writableComputedSignal(
  () => `${firstName()} ${lastName()}`,
  (val) => {
    const [first, last] = val.split(' ');
    firstName.set(first);
    lastName.set(last);
  },
);

批处理

import { signalBatch, signalUntrack } from '@lytjs/core-signal';

// 批量更新
signalBatch(() => {
  a.set(10);
  b.set(20);
  // 只触发一次通知
});

// 取消追踪
const value = signalUntrack(() => a());

生命周期钩子

import {
  onMounted,
  onUnmounted,
  onUpdated,
  onBeforeMount,
  onBeforeUnmount,
  onBeforeUpdate,
  onErrorCaptured,
} from '@lytjs/core-signal';

const App = defineComponent({
  setup() {
    onMounted(() => {
      console.log('组件已挂载');
    });

    onUnmounted(() => {
      console.log('组件已卸载');
    });

    return () => {
      // Signal 渲染函数
    };
  },
});

响应式 API

从 @lytjs/reactivity 重导出:

import {
  // Signal
  signal,
  computed,
  writableComputedSignal,
  readonlySignal,
  set,
  update,
  valueOf,
  signalBatch,
  signalUntrack,
  // Ref(与 Signal 互操作)
  ref,
  reactive,
  computed as computedRef,
  watch,
  watchEffect,
} from '@lytjs/core-signal';

Signal vs Ref

| 特性 | Signal | Ref | | -------- | ----------------- | ---------------- | | 读取 | count() | count.value | | 写入 | count.set() | count.value = | | 更新 | count.update() | 手动更新 | | 批量 | signalBatch() | batch() | | 取消追踪 | signalUntrack() | untrack() | | 适用 | 细粒度响应 | 对象响应式 |

类型定义

import type {
  App,
  AppConfig,
  Component,
  ComponentOptions,
  ComponentPublicInstance,
  Signal,
  ComputedSignal,
  WritableComputedSignal,
} from '@lytjs/core-signal';

相关包