npm i @leocode/rxstores @leocode/rxstores-react
yarn add @leocode/rxstores @leocode/rxstores-react
Info: This README assumes that you already know how to use RxStores.
// stores/some.store.ts
import { Store } from '@leocode/rxstores';
export interface SomeModel { name: string; }
export class SomeStore extends Store<SomeModel> {
...
updateModel() { ... }
}
// components/SomeComponent.tsx
import React from 'react';
import { useStore } from '@leocode/rxstores-react';
import { SomeStore } from '../stores/some.store';
const SomeComponent: React.FC = () => {
const [data, methods] = useStore(SomeStore);
return (
<p>{data.name}</p>
<button onClick={methods.updateModel}>Update</button>
);
}
This is not done yet.