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

iaktta

v0.2.7

Published

state management

Downloads

8

Readme

iaktta

A small observable state container

I would recommend you stick to the more popular state management libraries.

Installing

npm install iaktta

Example

import { observable, createObserverHook } from 'iaktta';
import { h, render } from 'preact';
import { useState, useEffect } from 'preact/hooks';
const useObserver = createObserverHook(useState, useEffect);

const model = observable({ counter: 0 });
const increment = () => model.counter ++;
const decrement = () => model.counter --;

const Counter = () => useObserver(() => (
    <div>
        <button onClick={decrement}>-</button>
        <strong>{model.counter}</strong>
        <button onClick={increment}>+</button>
    </div>
));

render(<Counter />, document.body);

Size

Bundlephobia

Public functions

observable

The observable function creates a new observable object.

When a property of this object is accessed or modified, its observers are notified.

import { observable } from 'iaktta';

const model = observable({ counter: 0 });
const inc = () => model.counter ++;

// also works with decorator syntax for class properties
class Model {
  @observable counter = 0;
  inc: () => { this.counter++; }
}

createObserverHook

createObserverHook is a function that creates a react/preact hook to create observers. it takes 'useState' and 'useEffect' parameters to be used.

import { observable, createObserverHook } from 'iaktta';
import { render, h } from 'preact';
import { useState, useEffect } from 'preact/hooks';
const useObserver = createObserverHook(useState, useEffect);

const model = observable({ counter: 0 });
const inc = () => model.counter ++;

const Example = () => useObserver(() => <div onClick={inc}>The count is {model.counter}</div>);

render(<Example />, document.body);

computed

A computed value caches the result of a potentially heavy operation, only re-running it if the underlying values have changed.

import { observable, computed } from 'iaktta';

const model = observable({ value: 100 });

const randomValue = computed(() => (Math.random() * model.value) | 0);
console.log(randomValue()); // 13
console.log(randomValue()); // 13
console.log(randomValue()); // 13

model.value = 200;
console.log(randomValue()); // 163

// also works with decorator syntax for class properties
class Model {
  @observable value = 100;
  @computed get randomValue() {
      return (Math.random() * this.value) | 0;
  }
}

run

The run function is a convenience function that will automatically run a function every time an observable watched by it changes. It returns a function that can be used to stop the automatic update.

import { run, observable } from 'iaktta';

const model = observable({ value: 100 });

// this will console log "value set to 100"
const cancel = run(() => {
  console.log('value set to ' + model.value);
});

// this will console log "value set to 200"
model.value = 200;

// cancel future invocations
cancel();

// this will not console log
model.value = 300;