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

lit-bloc-js

v1.0.11

Published

Lit-Html powered BLoc system for creating Javascript based UI.

Downloads

29

Readme

THIS LIB IS DEPRECATED

Use bloc-them instead. and no longer maintained.

Bloc

Business Logic Components: This pattern aims to extract away all business logics into components, which will manage UI states and will notify the UI to re-render themselves when this states changes.

Important classes

Bloc : All classes which needs to implement some business logic [be it for interacting with front end or backend systems], needs to be implemented in subclass of this class.

export class CounterBloc extends Bloc<number>{

  constructor(){
      super(0);
  }

  increment(){
      let n = this.state;
      n++;
      this.emit(n);
  }

  decrement(){
      let n = this.state;
      n--;
      this.emit(n);
  }
}

In above example number is state [state can be any js object] of this Bloc , which it tries to modify/manage.

BlocsProvider: This class will provide your blocs to rest all components in your DOM tree.

export class CounterBlocProvider extends BlocsProvider{
  constructor(){
      super([new CounterBloc()]);
  }

  builder(){
      return html`<div><slot></slot></div>`;
  }
}

BlocBuilder: This class listens for a state changes for a particular type and redraw its components based on it. A BlocBuilder can be provided a bloc directly too.


export class CounterBlocBuilder extends BlocBuilder<CounterBloc, number>{
  constructor(){
      super(CounterBloc);
  }

  increment=()=>{
    this.bloc?.increment();
  }

  decrement=()=>{
    this.bloc?.decrement();
  }

  builder(state: number){
      return html`
      <div>Current state is : ${state}</div>
      <div><button @click=${this.increment}>increment</button></div>
      <div><button @click=${this.decrement}>decrement</button></div>
      `;
  }
}

Important points about bloc builder designing:

  • In above example we have defined increment and decrement function with arrow function format, to preserve meaning of this. Else when @click event vinding binds a event listner the this will mean the button element rather than instance of blocbuilder.
  • Blocs can be provided a bloc directly too, rather than making it depended on BlocsProvider.
// the call to super will be 
super(CounterBloc, new CounterBloc());

Usage in HTML code:

<counter-bloc-provider>
    <div>
        <h1>Blocs demo</h1>
        <counter-bloc-builder></counter-bloc-builder>
    </div>
</counter-bloc-provider>

ReposProvider: This can used to hold up any other class that needs to be provided down the dom tree.

class MyMaths extends ReposProvider{
    constructor(){
        super([new Arithmatics(), new Integerals(), new Probability()])
    }
}

//and later the class can be retrieved an where in the dom tree.
ReposProvider.of(Arithmatic, this);

Publishing

Always run npm run build before each release.