README
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>
</>
)
};
Documentation
Examples
License
Lamp Luwak is MIT licensed.