import { useEffect, useState } from 'react';

export const useListener = (entity: any) => {
  const [listener, setListener] = useState<boolean>(false);
  const [listened, setListened] = useState<any>(null);

  useEffect(() => {
    setListened(entity);
  }, [entity, listener]);

  return [listened, () => setListener(!listener)];
};
