debouncer 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/debouncer/debounceable.rb +7 -1
- data/lib/debouncer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f9e8547ac8f499bf83f7ea0a798cbc0296d8e33
|
4
|
+
data.tar.gz: e585350713f4323b67f7c94c66b52c13929aa165
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 706f48631fa33382c9d219f6f64b1cd7416ef4bbc5d1bcc103a58318022c16e772395b31ca32ea338d273c2a1c9f8e82bf9047ad20f52c61542c699318dd5231
|
7
|
+
data.tar.gz: 665deabc223212af9b616d8509080908617d1490aaa34974b2fc9ce71f1cc99dbd49fde52b8890744b3aa25009dfd538c397fbb5654347ea03c18a7e5f6cf33f
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Debouncer
|
1
|
+
# Debouncer [![Build Status](https://travis-ci.org/hx/debouncer.svg?branch=master)](https://travis-ci.org/hx/debouncer)
|
2
2
|
|
3
3
|
Background thread debouncing for Ruby.
|
4
4
|
|
@@ -102,6 +102,8 @@ end
|
|
102
102
|
|
103
103
|
The `combine_messages` method will be called whenever `send_warning` is called. The first argument is the last value it returned, or an empty array if this is the first call for the thread. The second argument is an array of the arguments supplied to `send_warning`. It should return an array of arguments that will ultimately be passed to the original method.
|
104
104
|
|
105
|
+
If grouping is enabled, the first two arguments will not include the ID. Instead, it will be passed as the first argument. The reducer should not include the ID in the array it returns.
|
106
|
+
|
105
107
|
A reducer method is a good place to call `flush_*` if you hit some sort of limit or threshold. Just remember to still return the array of arguments you want to call.
|
106
108
|
|
107
109
|
```ruby
|
@@ -14,7 +14,13 @@ class Debouncer
|
|
14
14
|
immediate = "#{base_name}_immediately#{suffix}"
|
15
15
|
debouncer = "@#{base_name}#{SUFFIXES[suffix]}_debouncer"
|
16
16
|
extras = ''
|
17
|
-
|
17
|
+
if reduce_with
|
18
|
+
if grouped
|
19
|
+
extras << ".reducer { |old, new| [new.first, *self.#{reduce_with}(old[1..-1] || [], new[1..-1], new.first)] }"
|
20
|
+
else
|
21
|
+
extras << ".reducer { |old, new| self.#{reduce_with} old, new }"
|
22
|
+
end
|
23
|
+
end
|
18
24
|
extras << ".rescuer { |ex| self.#{rescue_with} ex }" if rescue_with
|
19
25
|
|
20
26
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
data/lib/debouncer/version.rb
CHANGED