turbo_boost-streams 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/builds/@turbo-boost/streams.js +1 -1
- data/app/assets/builds/@turbo-boost/streams.js.map +3 -3
- data/app/javascript/invoke.js +30 -20
- data/lib/turbo_boost/streams/version.rb +1 -1
- metadata +2 -2
data/app/javascript/invoke.js
CHANGED
@@ -15,26 +15,36 @@ function withInvokeEvents (receiver, detail, callback) {
|
|
15
15
|
|
16
16
|
target.dispatchEvent(new CustomEvent(invokeEvents.before, options))
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
18
|
+
// the before event can provide invoke instructions my modifying the event detail
|
19
|
+
// For example, { delay: 1000 } will delay the invocation by 1000ms
|
20
|
+
let { delay } = detail.invoke || {}
|
21
|
+
delay = delay || 0
|
22
|
+
|
23
|
+
const execute = () => {
|
24
|
+
const result = callback(object)
|
25
|
+
options.detail.result = result
|
26
|
+
target.dispatchEvent(new CustomEvent(invokeEvents.after, options))
|
27
|
+
|
28
|
+
let promise
|
29
|
+
if (result instanceof Animation) promise = result.finished
|
30
|
+
if (result instanceof Promise) promise = result
|
31
|
+
|
32
|
+
if (promise)
|
33
|
+
promise.then(
|
34
|
+
() => {
|
35
|
+
options.detail.promise = 'fulfilled'
|
36
|
+
target.dispatchEvent(new CustomEvent(invokeEvents.finish, options))
|
37
|
+
},
|
38
|
+
() => {
|
39
|
+
options.detail.promise = 'rejected'
|
40
|
+
target.dispatchEvent(new CustomEvent(invokeEvents.finish, options))
|
41
|
+
}
|
42
|
+
)
|
43
|
+
else target.dispatchEvent(new CustomEvent(invokeEvents.finish, options))
|
44
|
+
}
|
45
|
+
|
46
|
+
if (delay > 0) setTimeout(execute, delay)
|
47
|
+
else execute()
|
38
48
|
}
|
39
49
|
|
40
50
|
function invokeDispatchEvent (method, args, receivers) {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbo_boost-streams
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nate Hopkins (hopsoft)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|