const dimensionMarshalStopper = (marshal) => () => (next) => (action) => {
  // Not stopping a collection on a 'DROP' as we want a collection to continue
  if (
    // drag is finished
    action.type === "DROP_COMPLETE" ||
    action.type === "FLUSH" ||
    // no longer accepting changes once the drop has started
    action.type === "DROP_ANIMATE"
  ) {
    marshal.stopPublishing();
  }
  next(action);
};

export default dimensionMarshalStopper;
