Sha256: 799bcfb522b0dfa2e40a13427353e7a446098bdc07359d688b5af34f96a0a079

Contents?: true

Size: 1.65 KB

Versions: 16

Compression:

Stored size: 1.65 KB

Contents

import { Controller } from 'stimulus'
import StimulusReflex from 'stimulus_reflex'

/* This is your ApplicationController.
 * All StimulusReflex controllers should inherit from this class.
 *
 * Example:
 *
 *   import ApplicationController from './application_controller'
 *
 *   export default class extends ApplicationController { ... }
 *
 * Learn more at: https://docs.stimulusreflex.com
 */
export default class extends Controller {
  connect () {
    StimulusReflex.register(this)
  }

  /* Application-wide lifecycle methods
   *
   * Use these methods to handle lifecycle concerns for the entire application.
   * Using the lifecycle is optional, so feel free to delete these stubs if you don't need them.
   *
   * Arguments:
   *
   *   element - the element that triggered the reflex
   *             may be different than the Stimulus controller's this.element
   *
   *   reflex - the name of the reflex e.g. "Example#demo"
   *
   *   error/noop - the error message (for reflexError), otherwise null
   *
   *   reflexId - a UUID4 or developer-provided unique identifier for each Reflex
   */

  beforeReflex (element, reflex, noop, reflexId) {
    // document.body.classList.add('wait')
  }

  reflexSuccess (element, reflex, noop, reflexId) {
    // show success message
  }

  reflexError (element, reflex, error, reflexId) {
    // show error message
  }

  reflexHalted (element, reflex, error, reflexId) {
    // handle aborted Reflex action
  }

  afterReflex (element, reflex, noop, reflexId) {
    // document.body.classList.remove('wait')
  }

  finalizeReflex (element, reflex, noop, reflexId) {
    // all operations have completed, animation etc is now safe
  }
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
stimulus_reflex-3.4.2 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
stimulus_reflex-3.5.0.pre8 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
stimulus_reflex-3.5.0.pre7 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
stimulus_reflex-3.5.0.pre6 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
stimulus_reflex-3.5.0.pre5 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
stimulus_reflex-3.5.0.pre4 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
stimulus_reflex-3.5.0.pre3 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
stimulus_reflex-3.5.0.pre2 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
stimulus_reflex-3.5.0.pre1 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
stimulus_reflex-3.5.0.pre0 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
stimulus_reflex-3.4.1 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
stimulus_reflex-3.4.0 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
stimulus_reflex-3.4.0.pre9 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
stimulus_reflex-3.4.0.pre8 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
stimulus_reflex-3.4.0.pre7 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
stimulus_reflex-3.4.0.pre6 lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt