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

@kookapp/logic-models

v1.0.3

Published

KookApp Logic Models

Readme

什么是逻辑模型

这些模块(如SelectModelPager

  1. SelectModel: 封装了选择行为的逻辑,管理选中状态
  2. Pager: 封装了分页逻辑,管理分页状态和数据获取 特点:
  • 它们都是无UI的纯逻辑封装,因此可以在任何前端框架中使用
  • 它们管理特定的数据和状态,抽象了领域中相对复杂的部分
  • 它们提供方法来操作这些数据,使业务逻辑更简单和直观
  1. 它们确实是"模型",因为:

    • 封装了特定领域的数据和行为
    • 管理内部状态
    • 提供操作这些状态的方法
  2. 增加"逻辑"修饰词:

    • 区分于传统MVC中的数据模型
    • 强调其封装特定业务逻辑的性质

这种模型设计方式符合现代前端架构的最佳实践,将业务逻辑从UI中剥离出来,提高了代码的可维护性和可测试性以及可扩展性。

如何在框架中使用

  1. 通过搭配的 对应框架的 logicModel-xxx 模块,来使用这些逻辑模型,比如 react 中使用 logicModel-react ,比如:
import { useSelectModel } from '@kookapp/logic-models-react'

const App = () => {
  const data = ['选项1', '选项2']
  const selectModel = useSelectModel(data)
  return (
    <div>
      <h1>选择模型示例</h1>
      <button onClick={() => selectModel.select('选项1')}>选择选项1</button>
      <button onClick={() => selectModel.select('选项2')}>选择选项2</button>
      <p>当前选择:{selectModel.selected}</p>
    </div>
  )
}
  1. 或者直接使用 logicModels 中的模型类,来创建和管理模型实例,比如:
import { SelectModel } from '@kookapp/logic-models'
const selectModel = new SelectModel()