Sha256: 980ab0304e822941b95728468970caa89b9f9f8bb21c4ef8deaed2b70f6f4c91

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 Bytes

Contents

MultiSignalRelay = require "cronus/multi_signal_relay"

SimpleSubmitter = require "hoarder/submitter/submitters/simple_submitter"
PollingSubmitter = require "hoarder/submitter/submitters/polling_submitter"

#
# @author - Tim Shelburne <tim@musiconelive.com>
#
# a class to handle submitting forms
#
class FormSubmitter
  constructor: (@submitters)->
    successSignals = []
    errorSignals = []
    for submitter in @submitters
      successSignals.push submitter.submittedWithSuccess
      errorSignals.push submitter.submittedWithError

    @submittedWithSuccess = new MultiSignalRelay(successSignals)
    @submittedWithError = new MultiSignalRelay(errorSignals)

  @default: (pollingUrl)->
    new @([ new SimpleSubmitter(), new PollingSubmitter(pollingUrl, 1000)])

  submitForm: (form)->
    for submitter in @submitters
      submitter.submitForm(form) if submitter.canSubmit(form)

return FormSubmitter

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hoarder-js-0.0.1 assets/scripts/coffee/hoarder/submitter/form_submitter.coffee