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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@dodona/lit-state

v1.1.1

Published

`@dodona/lit-state` is a state management system for [lit](https://lit.dev/) that combines the best of [litState](https://www.npmjs.com/package/lit-element-state) and [@lit-app/state](https://www.npmjs.com/package/@lit-app/state).

Readme

Lit state

@dodona/lit-state is a state management system for lit that combines the best of litState and @lit-app/state.

It is designed to be easy to use, with great typescript support and minimal boilerplate code.

This package has been in active use in production at Dodona, with thousands of users daily, since early 2023.

Getting started

Install the package via npm or yarn:

yarn add @dodona/lit-state
# or
npm install @dodona/lit-state

Usage

Statefull objects inherit from State and use the stateProperty decorator for properties that should be tracked.

class CounterState extends State {
  @stateProperty() count = 0;
}

// global state that can be shared between components
const counterState = new CounterState();

Components that want to use state inherit from LitElement and use the StateController to track state properties that are read during render. You only need to define the StateController once per component, it will automatically track all state properties that are read during render and subscribe to them.

class CounterComponent extends LitElement {
  private stateController = new StateController(this);

  render() {
    return html`
      <div>Count: ${counterState.count}</div>
      <button @click=${() => counterState.count++ }>Increment</button>
    `;
  }
}

API

The package exports the following:

  • State a class that inherits from EventTarget. It can be subscribed to and will dispatch an event to all subscribers when any of its properties change. It also record every read of it's properties to the stateRecorder. All credits to @lit-app/state for the idea to use EventTarget to avoid reinventing an event system.
  • stateProperty a decorator used for properties in the State class. This decorator overwrites the get and set methods to make sure events get dispatched.
  • stateRecorder instance. A global instance that records every property of a state that gets read between its start and finish. Credits to litState.
  • StateController a ReactiveController that uses the stateRecorder to track all stateProperties that are read during a render cycle. It then subscribes to the relevant states to trigger an update of its host every time one of those stateProperties changes. Thanks to @lit-app/state for introducing me to controllers for this use case.
  • StateEvent a custom event that signifies state changes. Credits @lit-app/state
  • StateMap extends State and implements Map. It notifies subscribers of key changes as if it where stateProperties.

Contributing

Contributions are welcome! Please open an issue or a pull request on GitHub. See package.json for scripts to build, test and lint the project.