babel-plugin-lamp-luwak

Babel plugin for automatic SSR


Keywords
babel plugin lamp-luwak ssr, action, dependency-injection, dispatcher, modular, react-store, service-architecture, service-oriented, state-management
License
MIT
Install
npm install babel-plugin-lamp-luwak@4.2.2

Documentation

lamp-luwak

lamp-luwak is no longer maintained. Please use realar or use-between instead of.

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.