class Turbo::ThreadDebouncer
after the debounced logic triggers.
A decorated debouncer that will store instances in the current thread clearing them
def self.for(key, delay: Turbo::Debouncer::DEFAULT_DELAY)
def self.for(key, delay: Turbo::Debouncer::DEFAULT_DELAY) Thread.current[key] ||= new(key, Thread.current, delay: delay) end
def debounce
def debounce debouncer.debounce do yield.tap do thread[key] = nil end end end
def initialize(key, thread, delay: )
def initialize(key, thread, delay: ) @key = key @debouncer = Turbo::Debouncer.new(delay: delay) @thread = thread end