@giant-leaps/nanostores-stencil
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Nano Stores Stencil

+

Stencil integration for Nano Stores, a tiny state manager with many atomic tree-shakable stores.

  • Small. Less than 1 KB. Zero dependencies.
  • Fast. With small atomic and derived stores, you do not need to call the selector function for all components on every store change.
  • Tree Shakable. The chunk contains only stores used by components in the chunk.
  • Was designed to move logic from components to stores.
  • It has good TypeScript support.

Quick start

Install it using one of the following commands:

npm

npm add nanostores @giant-leaps/nanostores-stencil

bun

bun add nanostores @giant-leaps/nanostores-stencil

pnpm

pnpm add nanostores @giant-leaps/nanostores-stencil

yarn

yarn add nanostores @giant-leaps/nanostores-stencil

Use it as a decorator with @useStores:

 import { Component } from '@stencil/core';
 import { atom } from 'nanostores';
 import { MultiStoreSubscription } from '@giant-leaps/nanostores-stencil';

 const count1 = atom(0);
 const count2 = atom(0);

 @Component({
   tag: 'my-element',
    // additional options
  })
  class MyElement {

  private countsSubscription = new MultiStoreSubscription(this, [count1, count2]);

  render() {
   const [$count1, $count2] = countsSubscription.values;
   return html\`Count 1: \${count1}\, Count 2: \${count2}\`;
  }
 }

Package Sidebar

Install

npm i @giant-leaps/nanostores-stencil

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

9.32 kB

Total Files

9

Last publish

Collaborators

  • giantleaps