Created
March 24, 2021 18:46
-
-
Save KevinGutowski/a7fd9eef9bd68ae1ff61c78fe53f5b2b to your computer and use it in GitHub Desktop.
Async network download
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let sketch = require('sketch') | |
var fiber = require('sketch/async').createFiber() | |
var url = NSURL.URLWithString("https://github.com/KevinGutowski/Testing/raw/main/Test.sketch") | |
let session = NSURLSession.sharedSession() | |
let block = __mocha__.createBlock_function('v32@?0@"NSURL"8@"NSURLResponse"16@"NSError"24', (url,response,error) => { | |
try { | |
let docError = MOPointer.alloc().init() | |
var newDocument = MSDocument.alloc().init(); | |
newDocument.readFromURL_ofType_error(url,"com.bohemiancoding.sketch.drawing", docError); | |
console.log(sketch.fromNative(newDocument)) | |
} catch(e) { | |
console.log(e) | |
} | |
fiber.cleanup() | |
} | |
)) | |
let downloadTask = session.downloadTaskWithURL_completionHandler(url,block) | |
downloadTask.resume() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment