import { fromEvent, merge } from 'rxjs'

export const createInputObservable = ({ elements, types, event = 'change' }) => {
  return merge(
    ...elements.filter(element => types.indexOf(element.type) !== -1).map(element => fromEvent(element, event)),
  )
}

export const createSelectObservable = ({ elements, event = 'change' }) => {
  return merge(...elements.map(element => fromEvent(element, event)))
}

export const createFormObservable = ({ element, event = 'submit' }) => {
  return fromEvent(element, event)
}
