2.11.96 • Published 10 months ago

hermes-io v2.11.96

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

hermes-io

A lightweight React library that allows communication between components by using the observer pattern and the hook api.

Documentation

See: https://hermes-io-docs.vercel.app/

Usage

import { MicroStore } from "hermes-io";

export const store = new MicroStore();
export const storeId = 'counter-id';
export const actions = {
  INCREMENT: "INCREMENT",
  DECREMENT: "DECREMENT"
};

export default function reducer(store, action) {
  const actionsMap = {
    [actions.INCREMENT]: () => {
      store.state.count += 1;
    },
   [actions.DECREMENT]: () => {
      store.state.count -= 1;
    },
  };
  return actionsMap[action.payload.type]();
};
import { useObservableStore } from "hermes-io";
import { store, storeId } from "@/store";
import reducer, { actions } from "@/reducer";

export default function App() {
  useObservableStore(storeId, { count: 0 }, reducer, store);

  const increment = () => store.mutate({ type: events.INCREMENT });

  const decrement = () => store.mutate({ type: events.DECREMENT });

  return (
    <div>
      <Counter />
      <RenderTracker />
      <button onClick={increment}>Increment</button>
      <button onClick={decrement}>Decrement</button>
    </div>
  );
};
import { useMutations } from "hermes-io";
import { store, storeId } from "@/store";
import { actions } from "@/reducer";

export function Counter() {
  const { state, onEvent } = useMutations({
    initialState: { count: 0 },
    id: storeId,
    store,
  });
  const handleEvent = (value, _resolver, _setNoUpdate, currentState) => ({ count: currentState.count }); 

  onEvent(actions.INCREMENT, handleEvent);
  onEvent(actions.DECREMENT, handleEvent);

  return <h1>Counter: {state.count}</h1>;
}

Devtool

Install from chrome web store here

chrome extension

2.11.93

12 months ago

2.11.94

11 months ago

2.11.95

11 months ago

2.11.96

10 months ago

2.11.81

1 year ago

2.11.82

1 year ago

2.11.83

1 year ago

2.11.84

1 year ago

2.11.85

1 year ago

2.11.86

1 year ago

2.11.87

1 year ago

2.11.88

1 year ago

2.11.89

1 year ago

2.11.90

1 year ago

2.11.91

1 year ago

2.11.92

1 year ago

2.10.81

1 year ago

2.9.81

1 year ago

2.8.70

1 year ago

2.9.82

1 year ago

2.9.80

1 year ago

2.9.85

1 year ago

2.8.74

1 year ago

2.9.86

1 year ago

2.8.73

1 year ago

2.9.83

1 year ago

2.8.72

1 year ago

2.9.84

1 year ago

2.8.71

1 year ago

2.9.89

1 year ago

2.9.87

1 year ago

2.9.88

1 year ago

2.8.52

1 year ago

2.8.51

1 year ago

2.8.56

1 year ago

2.8.55

1 year ago

2.8.54

1 year ago

2.8.53

1 year ago

2.8.59

1 year ago

2.8.58

1 year ago

2.8.57

1 year ago

2.9.74

1 year ago

2.8.63

1 year ago

2.9.75

1 year ago

2.8.62

1 year ago

2.8.61

1 year ago

2.8.60

1 year ago

2.9.78

1 year ago

2.8.67

1 year ago

2.9.79

1 year ago

2.8.66

1 year ago

2.9.76

1 year ago

2.8.65

1 year ago

2.9.77

1 year ago

2.8.64

1 year ago

2.8.69

1 year ago

2.8.68

1 year ago

2.7.51

1 year ago

2.6.51

1 year ago

2.6.50

2 years ago

2.5.49

2 years ago

2.5.50

2 years ago

2.4.49

2 years ago

2.4.47

2 years ago

2.4.46

2 years ago

2.4.45

2 years ago

2.4.44

2 years ago

2.3.42

2 years ago

2.3.44

2 years ago

2.3.43

2 years ago

2.2.39

2 years ago

2.2.38

2 years ago

2.2.42

2 years ago

2.2.41

2 years ago

2.2.37

2 years ago

2.2.35

2 years ago

2.2.36

2 years ago

2.2.34

2 years ago

2.2.31

2 years ago

2.2.32

2 years ago

2.2.30

2 years ago

2.2.29

2 years ago

2.2.17

2 years ago

2.2.18

2 years ago

2.2.16

2 years ago

2.2.19

2 years ago

2.2.28

2 years ago

2.2.26

2 years ago

2.2.27

2 years ago

2.2.25

2 years ago

2.2.20

2 years ago

2.2.21

2 years ago

2.2.9

3 years ago

2.2.8

3 years ago

2.2.15

3 years ago

2.2.13

3 years ago

2.2.5

3 years ago

2.2.14

3 years ago

2.2.4

3 years ago

2.2.11

3 years ago

2.2.7

3 years ago

2.2.12

3 years ago

2.2.6

3 years ago

2.2.10

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.2.3

3 years ago

2.1.0

3 years ago

1.0.0

3 years ago