This package has been deprecated

Author message:

lamp-luwak is no longer maintained. Please use use-between or realar instead of (if possible).

lamp-luwak
TypeScript icon, indicating that this package has built-in type declarations

4.2.2 • Public • Published

lamp-luwak

lamp-luwak logo

Flexible state management for React

npm npm type definitions npm bundle size build status code coverage

Introduction

Multistore state management with service ideology and module architecture for React. You can organize the code of your application by service-stores. Single instantiated instances of classes or function factory with a store inside at any place of your app code.

  • Service-oriented and multistore architecture
  • Update view components only dependent of changed stores
  • No use Context API inside
  • TypeScript supported
  • Lightweight (~3Kb)

Install

npm i --save lamp-luwak
# or 
yarn add lamp-luwak

Basic Usage

import React from 'react';
import { set, useService } from 'lamp-luwak';
 
class CounterService {
  state = 0; // Initial state
  increment() {
    set(this, (state) => state + 1);
  }
  decrement() {
    set(this, (state) => state - 1);
  }
}
 
const Counter = () => {
  const counter = useService(CounterService);
  return (
    <>
      <button onClick={() => counter.increment()}>+</button>
      <button onClick={() => counter.decrement()}>-</button>
      <p>Counter{counter.state}</p>
    </>
  )
};

Example on codesandbox

Documentation

The Russian article

Examples

License

Lamp Luwak is MIT licensed.

Package Sidebar

Install

npm i lamp-luwak

Weekly Downloads

4

Version

4.2.2

License

MIT

Unpacked Size

144 kB

Total Files

25

Last publish

Collaborators

  • betula