Sha256: 422b420af96c69ebfb4bb2fc6e19cd12285009017e6b3e95d149e6e341625a16

Contents?: true

Size: 1.85 KB

Versions: 5

Compression:

Stored size: 1.85 KB

Contents

import ApplicationController from './application_controller'

/* This is the custom StimulusReflex controller for <%= class_name %>Reflex.
 * Learn more at: https://docs.stimulusreflex.com
 */
export default class extends ApplicationController {
  /* Reflex specific lifecycle methods.
   * Use methods similar to this example to handle lifecycle concerns for a specific Reflex method.
   * Using the lifecycle is optional, so feel free to delete these stubs if you don't need them.
   *
   * Example:
   *
   *   <a href="#" data-reflex="<%= class_name %>Reflex#example">Example</a>
   *
   * 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. "<%= class_name %>Reflex#example"
   *
   *   error - error message from the server
   */

<% if actions.empty? -%>
  // beforeUpdate(element, reflex) {
  //  element.innerText = 'Updating...'
  // }

  // updateSuccess(element, reflex) {
  //   element.innerText = 'Updated Successfully.'
  // }

  // updateError(element, reflex, error) {
  //   console.error('updateError', error);
  //   element.innerText = 'Update Failed!'
  // }
<% end -%>
<% actions.each do |action| -%>
  // <%= "before_#{action}".camelize(:lower) %>(element, reflex) {
  //  console.log("before <%= action %>", element, reflex)
  // }

  // <%= "#{action}_success".camelize(:lower) %>(element, reflex) {
  //   console.log("<%= action %> success", element, reflex)
  // }

  // <%= "#{action}_error".camelize(:lower) %>(element, reflex, error) {
  //   console.error("<%= action %> error", element, reflex, error)
  // }

  // <%= "after_#{action}".camelize(:lower) %>(element, reflex, error) {
  //   console.log("after <%= action %>", element, reflex, error)
  // }
<%= "\n" unless action == actions.last -%>
<% end -%>
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stimulus_reflex-3.3.0.pre4 lib/generators/templates/app/javascript/controllers/%file_name%_controller.js.tt
stimulus_reflex-3.3.0.pre3 lib/generators/templates/app/javascript/controllers/%file_name%_controller.js.tt
stimulus_reflex-3.3.0.pre2 lib/generators/templates/app/javascript/controllers/%file_name%_controller.js.tt
stimulus_reflex-3.3.0.pre1 lib/generators/templates/app/javascript/controllers/%file_name%_controller.js.tt
stimulus_reflex-3.3.0.pre0 lib/generators/templates/app/javascript/controllers/%file_name%_controller.js.tt