Skip to content

joshleblanc/stimulus_reflex_globalid

Repository files navigation

StimulusReflexGlobalid

StimulusReflexGlobalId maps global IDs to instance variables during a reflex.

Installation

bundle add stimulus_reflex_globalid

Usage

No setup is required to use this library.

In your markup, specific data-reflex and data attributes as normal

<button data-reflex="click->MyReflex#handle_click" data-foo="<%= @foo.to_global_id %>"

When the button is clicked, an instance variable @foo will be created, set to @foo.

class MyReflex < ApplicationReflex
  def handle_click
    p @foo
  end
end

You can also use signed IDs.

Configuring

You can turn off signed/unsigned IDs by configuring the gem.

StimulusReflexGlobalid::Engine.configure do |config|
  config.allow_signed = false # default true
  config.allow_unsigned = false # default true
end

License

The gem is available as open source under the terms of the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages