2.11.96 • Published 6 months ago

hermes-io v2.11.96

Weekly downloads
-
License
MIT
Repository
-
Last release
6 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

8 months ago

2.11.94

8 months ago

2.11.95

7 months ago

2.11.96

6 months ago

2.11.81

10 months ago

2.11.82

10 months ago

2.11.83

10 months ago

2.11.84

10 months ago

2.11.85

10 months ago

2.11.86

10 months ago

2.11.87

10 months ago

2.11.88

10 months ago

2.11.89

10 months ago

2.11.90

10 months ago

2.11.91

10 months ago

2.11.92

10 months ago

2.10.81

10 months ago

2.9.81

11 months ago

2.8.70

1 year ago

2.9.82

11 months ago

2.9.80

12 months ago

2.9.85

11 months ago

2.8.74

1 year ago

2.9.86

11 months ago

2.8.73

1 year ago

2.9.83

11 months ago

2.8.72

1 year ago

2.9.84

11 months ago

2.8.71

1 year ago

2.9.89

11 months ago

2.9.87

11 months ago

2.9.88

11 months 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

12 months ago

2.8.62

1 year ago

2.8.61

1 year ago

2.8.60

1 year ago

2.9.78

12 months ago

2.8.67

1 year ago

2.9.79

12 months ago

2.8.66

1 year ago

2.9.76

12 months ago

2.8.65

1 year ago

2.9.77

12 months 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

1 year ago

2.5.49

1 year ago

2.5.50

1 year ago

2.4.49

1 year ago

2.4.47

1 year ago

2.4.46

1 year ago

2.4.45

1 year ago

2.4.44

1 year ago

2.3.42

1 year ago

2.3.44

1 year ago

2.3.43

1 year ago

2.2.39

1 year ago

2.2.38

1 year ago

2.2.42

1 year ago

2.2.41

1 year 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

2 years ago

2.2.8

2 years ago

2.2.15

2 years ago

2.2.13

2 years ago

2.2.5

2 years ago

2.2.14

2 years ago

2.2.4

2 years ago

2.2.11

2 years ago

2.2.7

2 years ago

2.2.12

2 years ago

2.2.6

2 years ago

2.2.10

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.2.3

2 years ago

2.1.0

3 years ago

1.0.0

3 years ago