aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/src/modules/socketio/hooks.ts
blob: 741fa5f4afec9fcba6b4db9183eef94cc6aac753 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import { useEffect } from "react";
import Socketio from ".";
import { LOG } from "../../utilities/console";

export function useSocketIOReducer(reducer: SocketIO.Reducer) {
  useEffect(() => {
    Socketio.addReducer(reducer);
    LOG("info", "listening to SocketIO event", reducer.key);
    return () => {
      Socketio.removeReducer(reducer);
    };
  }, [reducer]);
}