I have 3 promises, each works individually:
DataManager.reverseGeoCodePromise("42.527328", longitude: "-83.146928").then { data in
print("Zip \(data)")
}
DataManager.getEnviroUVWithZipPromise("48073").then { data in
print("UV \(data.getUVIndex())")
}
DataManager.getCurrentForZipPromise("48073").then { data in
print("AirNow \(data[0].Latitude)")
}
I have been trying to follow (sparce) swift documentation on promisekit 3 (and exhausted google and stack overflow). My attempt at chaining these async methods is not acting synchronously at all - all the print(data) are null, but the breakpoints in the methods shows data.
DataManager.reverseGeoCodePromise("42.527328", longitude: "-83.146928").then { data in
print("Promise Zip \(data)")
}.then { data -> Void in
DataManager.getEnviroUVWithZipPromise("48073")
print("Promise Enviro \(data)")
}.then { data -> Void in
DataManager.getCurrentForZipPromise("48073")
print("Promise AirNow \(data)")
}.error { error in
print("Promise doh!")
}
I would like data from the first call (zip) to be passed to subsequent calls and to be able to work with data from all calls after the last. Any insight greatly appreciated!