Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local path = yourBaseRemoteURL
- local init = coroutine.create(
- function(items, downloader)
- local total = #items
- local item = table.remove(items)
- while item do
- network.download(path..item, "GET", downloader, item)
- end
- repeat
- table.insert(coroutine.yield())
- until items[#total]
- -- process collected resources
- end
- )
- local function downloadProcessor(outcome)
- if outcome.isError then
- local item = outcome.response
- network.download(path..item, "GET", downloadProcessor, item)
- else
- coroutine.resume(init, event.response)
- end
- end
- assert(coroutine.resume(init, {"file1.json", "file2.html"}, downloadProcessor))
Advertisement
Add Comment
Please, Sign In to add comment