import { useBookingTicket } from "./bookingTicket";
import { useActiveExecute } from "./useActiveExecute";
import { useMemoizedFn } from 'ahooks';
var useCartChangeEffect = function useCartChangeEffect() {
  var bookingTicket = useBookingTicket();
  var _useActiveExecute = useActiveExecute(),
    executeIfActive = _useActiveExecute.executeIfActive;
  var onCartChange = useMemoizedFn(function (type, list) {
    var _bookingTicket$effect;
    bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$effect = bookingTicket.effectsEmit) === null || _bookingTicket$effect === void 0 || _bookingTicket$effect.call(bookingTicket, 'onCartChange', {
      type: type,
      list: list
    });
  });
  var effectOn = function effectOn(fn) {
    var _bookingTicket$effect2;
    return bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$effect2 = bookingTicket.effectsOn) === null || _bookingTicket$effect2 === void 0 ? void 0 : _bookingTicket$effect2.call(bookingTicket, 'onCartChange', executeIfActive(fn));
  };
  return {
    onCartChange: onCartChange,
    effectOn: effectOn
  };
};
export default useCartChangeEffect;