opal-async 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +1 -1
- data/README.md +32 -9
- data/VERSION +1 -1
- data/opal/async/countdown.rb +2 -0
- data/opal/async/ext/array.rb +20 -30
- data/opal/async/ext/kernel.rb +11 -0
- data/opal/async/ext.rb +1 -0
- data/opal/async/interval.rb +2 -0
- data/opal/async/task.rb +2 -0
- data/opal/async/timeout.rb +2 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a112b35fc92cf3947ab6225bb32afa7a5e65bd4758a2f644a0d62b74a5ba993
|
4
|
+
data.tar.gz: 142670ab07eb81daf6246d4cf0a677c3d441e0fbafc458709f50c5eed4ac3a05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1c059e8d548c9675a3865969e867090d863815ace67a0b95a0df4bcece2a26e8dd9a42922e990b32abe0e28c8d8273d98a1940169ef5f0699baf74774bc8e1a
|
7
|
+
data.tar.gz: 7b23df0ceb45b01227436e96175b65ad00f90ce223fbfc7c6ec5b25f4578a1a73cfff5e8493830b25e4f84d80afc99ca6f60d6dcd94635202900ae8bcf4c8549
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 1.4.1
|
4
|
+
|
5
|
+
- Add `# backtick_javascript: true` where needed to satisfy new Opal requirement
|
6
|
+
|
7
|
+
## 1.4.0
|
8
|
+
|
9
|
+
- Drop `Array#cycle` and `Array#each` overrides and re-implement as `Array#async_cycle` and `Array#async_each`
|
10
|
+
- Asynchronous `Kernel#async_loop` alternative to `Kernel#loop`
|
11
|
+
|
3
12
|
## 1.3.0
|
4
13
|
|
5
14
|
- Asynchronous `Array#each` method that is web browser event loop friendly
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
# Opal: Async
|
1
|
+
# Opal: Async 1.4.1
|
2
2
|
[](https://badge.fury.io/rb/opal-async)
|
3
3
|
|
4
4
|
## Installation
|
5
5
|
|
6
6
|
Add this line to your application's Gemfile:
|
7
7
|
|
8
|
-
gem 'opal-async', '~> 1.
|
8
|
+
gem 'opal-async', '~> 1.4.1'
|
9
9
|
|
10
10
|
And then execute:
|
11
11
|
|
@@ -185,9 +185,9 @@ end
|
|
185
185
|
|
186
186
|
#### Array
|
187
187
|
|
188
|
-
The follow `Array` methods have been
|
189
|
-
- `Array#
|
190
|
-
- `Array#
|
188
|
+
The follow `Array` methods have been added to work asynchronously via `Async::Task`:
|
189
|
+
- `Array#async_cycle`
|
190
|
+
- `Array#async_each`
|
191
191
|
|
192
192
|
This makes them not block the web browser event loop, thus allowing other tasks to update the DOM unhindered while running.
|
193
193
|
|
@@ -197,12 +197,34 @@ Example:
|
|
197
197
|
require 'async/ext/array' # not needed if you called `require 'async/ext'`
|
198
198
|
|
199
199
|
Async::Task.new do
|
200
|
-
[1,2,3,4].
|
200
|
+
[1,2,3,4].async_cycle do |n|
|
201
201
|
puts n
|
202
202
|
Async::Task.new do
|
203
|
-
# make a DOM update
|
203
|
+
# make a DOM update that is not blocked
|
204
204
|
end
|
205
|
-
sleep(1)
|
205
|
+
sleep(1)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
```
|
209
|
+
|
210
|
+
#### Kernel
|
211
|
+
|
212
|
+
The follow `Kernel` method has been added to work asynchronously via `Async::Task`:
|
213
|
+
- `Array#async_loop`
|
214
|
+
|
215
|
+
This makes it not block the web browser event loop, thus allowing other tasks to update the DOM unhindered while running.
|
216
|
+
|
217
|
+
Example:
|
218
|
+
|
219
|
+
```ruby
|
220
|
+
require 'async/ext/kernel' # not needed if you called `require 'async/ext'`
|
221
|
+
|
222
|
+
Async::Task.new do
|
223
|
+
async_loop do
|
224
|
+
Async::Task.new do
|
225
|
+
# make a DOM update that is not blocked
|
226
|
+
end
|
227
|
+
sleep(1)
|
206
228
|
end
|
207
229
|
end
|
208
230
|
```
|
@@ -210,7 +232,8 @@ end
|
|
210
232
|
## In The Wild
|
211
233
|
|
212
234
|
opal-async is currently used in:
|
213
|
-
- [Glimmer DSL for
|
235
|
+
- [Glimmer DSL for Web](https://github.com/AndyObtiva/glimmer-dsl-web) (Ruby in the Browser Web GUI Frontend Library)
|
236
|
+
- [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) (Pure-Ruby Web GUI and Auto-Webifier of Desktop Apps)
|
214
237
|
|
215
238
|
## Change Log
|
216
239
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.4.1
|
data/opal/async/countdown.rb
CHANGED
data/opal/async/ext/array.rb
CHANGED
@@ -1,40 +1,30 @@
|
|
1
1
|
require 'async/task'
|
2
2
|
|
3
3
|
class Array
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
block.call(array.shift)
|
17
|
-
Async::Task.new(&looper) unless array.empty?
|
18
|
-
end
|
4
|
+
def async_cycle(n=nil, &block)
|
5
|
+
array = self * n unless n.nil?
|
6
|
+
index = 0
|
7
|
+
looper = lambda do
|
8
|
+
if n.nil?
|
9
|
+
block.call(self[index])
|
10
|
+
index += 1
|
11
|
+
index = index % self.size
|
12
|
+
Async::Task.new(&looper)
|
13
|
+
else
|
14
|
+
block.call(array.shift)
|
15
|
+
Async::Task.new(&looper) unless array.empty?
|
19
16
|
end
|
20
|
-
Async::Task.new(&looper)
|
21
|
-
else
|
22
|
-
cycle_without_opal_async(n, &block)
|
23
17
|
end
|
18
|
+
Async::Task.new(&looper)
|
24
19
|
end
|
25
20
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
looper
|
32
|
-
block.call(array.shift)
|
33
|
-
Async::Task.new(&looper) unless array.empty?
|
34
|
-
end
|
35
|
-
Async::Task.new(&looper)
|
36
|
-
else
|
37
|
-
each_without_opal_async(&block)
|
21
|
+
def async_each(&block)
|
22
|
+
array = self
|
23
|
+
index = 0
|
24
|
+
looper = lambda do
|
25
|
+
block.call(array.shift)
|
26
|
+
Async::Task.new(&looper) unless array.empty?
|
38
27
|
end
|
28
|
+
Async::Task.new(&looper)
|
39
29
|
end
|
40
30
|
end
|
data/opal/async/ext.rb
CHANGED
data/opal/async/interval.rb
CHANGED
data/opal/async/task.rb
CHANGED
data/opal/async/timeout.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ravenstine
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: opal
|
@@ -45,6 +45,20 @@ dependencies:
|
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: opal-sprockets
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
48
62
|
- !ruby/object:Gem::Dependency
|
49
63
|
name: rdoc
|
50
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,6 +151,7 @@ files:
|
|
137
151
|
- opal/async/enumerator.rb
|
138
152
|
- opal/async/ext.rb
|
139
153
|
- opal/async/ext/array.rb
|
154
|
+
- opal/async/ext/kernel.rb
|
140
155
|
- opal/async/ext/thread.rb
|
141
156
|
- opal/async/interval.rb
|
142
157
|
- opal/async/task.rb
|
@@ -166,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
181
|
- !ruby/object:Gem::Version
|
167
182
|
version: '0'
|
168
183
|
requirements: []
|
169
|
-
rubygems_version: 3.
|
184
|
+
rubygems_version: 3.3.6
|
170
185
|
signing_key:
|
171
186
|
specification_version: 4
|
172
187
|
summary: Provides non-blocking tasks and enumerators for Opal.
|