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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc5f4a757a39dabc8a7bc7efcb87631a7dd6809f0fd7da29b5b40ec23d436ea8
4
- data.tar.gz: b7c60f66044d9e0f49c2b0a49c18046bccfbd89364fbbdb18d62323cf5351991
3
+ metadata.gz: 6a112b35fc92cf3947ab6225bb32afa7a5e65bd4758a2f644a0d62b74a5ba993
4
+ data.tar.gz: 142670ab07eb81daf6246d4cf0a677c3d441e0fbafc458709f50c5eed4ac3a05
5
5
  SHA512:
6
- metadata.gz: bc8669beff060d5f91ffad0b6f1ee68d4708124bb5be87d6759eb67ee7c84211c9a6c6a624a73c1eca170ccb305817d13f6472c9c9986c5488b4afbf918929c1
7
- data.tar.gz: cf3fe071bb8e549e76e447a5bfd1e28afceb6385a6f005dbef96a8a2b0c77596fbcbeeb05e9901933f151da36d307353dc4c8c13f02fedb39302f2015a2b6d35
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
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015-2020 Ben Titcomb & Andy Maleh
1
+ Copyright (c) 2015-2024 Ben Titcomb & Andy Maleh
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # Opal: Async
1
+ # Opal: Async 1.4.1
2
2
  [![Gem Version](https://badge.fury.io/rb/opal-async.svg)](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.3.0'
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 amended to work asynchronously via `Async::Task` when triggered inside another `Async::Task` (auto-detects it):
189
- - `Array#cycle`
190
- - `Array#each`
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].cycle do |n|
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) # this does not block the event loop since it is transparently happening inside an Async::Task
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 Opal](https://github.com/AndyObtiva/glimmer-dsl-opal)
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.3.0
1
+ 1.4.1
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Async
2
4
  class Countdown
3
5
  def initialize time=0, intervals=1, step=1, &block
@@ -1,40 +1,30 @@
1
1
  require 'async/task'
2
2
 
3
3
  class Array
4
- alias cycle_without_opal_async cycle
5
- def cycle(n=nil, &block)
6
- if Async::Task.started? && block_given?
7
- array = self * n unless n.nil?
8
- index = 0
9
- looper = lambda do
10
- if n.nil?
11
- block.call(self[index])
12
- index += 1
13
- index = index % self.size
14
- Async::Task.new(&looper)
15
- else
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
- alias each_without_opal_async each
27
- def each(&block)
28
- if Async::Task.started? && block_given?
29
- array = self
30
- index = 0
31
- looper = lambda do
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
@@ -0,0 +1,11 @@
1
+ require 'async/task'
2
+
3
+ module Kernel
4
+ def async_loop(&block)
5
+ looper = lambda do
6
+ block.call
7
+ Async::Task.new(&looper)
8
+ end
9
+ Async::Task.new(&looper)
10
+ end
11
+ end
data/opal/async/ext.rb CHANGED
@@ -1,2 +1,3 @@
1
1
  require 'async/ext/thread'
2
2
  require 'async/ext/array'
3
+ require 'async/ext/kernel'
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Async
2
4
  class Interval
3
5
  def initialize time=0, &block
data/opal/async/task.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Async
2
4
  class Task
3
5
  class << self
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Async
2
4
  class Timeout
3
5
 
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.3.0
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: 2021-08-18 00:00:00.000000000 Z
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.1.4
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.