假设我有一个实现 do:[] every:40s 块的方法。块中有一个值数据,应该在每次延迟时返回。如何将其重新调整为 pharo 中的方法,如下所示:
Class>>updateMethod
"This is a method"
| scheduler data |
scheduler := TaskScheduler new.
scheduler start.
"refresh every 40 seconds"
scheduler
do: [a get: 'https://MyServer/json'.
Transcript show: 'Refreshing......'; cr.
data := NeoJSONReader fromString: a contents; cr.
every: 60 seconds