into your Package.swift file. And then run swift package update under command line.
Usage
While working with KKBOX’s Open API Swift SDK, you may write code with nested callback handling like this:
_ = try? self.API.fetchAccessTokenByClientCredential { result in
switch result {
case .error(let error):
print("\(error.localizedDescription)")
case .success(_):
_ = try? self.API.fetch(track: "4kxvr3wPWkaL9_y3o_") { result in
switch result {
case .error(let error):
print("\(error.localizedDescription)")
case .success(let track):
print("\(track)")
}
}
}
}
Promises fix the callback hells. After adding the extension, you can make the code above like this:
self.API.fetchAccessTokenByClientCredential().then { _ in
return self.API.fetch(track: "4kxvr3wPWkaL9_y3o_")
} .then { track in
print("\(track)")
} .catch { error in
print("\(error.localizedDescription)")
}
License
Copyright 2018-2019 KKBOX Technologies Limited
Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
KKBOX Open-API Swift SDK Promises Extension
Copyright 2018-2019 KKBOX Technologies Limited
Use KKBOX’s Swift SDK in a promising way.
Introduction
The project extends KKBOX’s Open API Swift SDK by adopting Google’s Promisises library. it provides an alternative way to do aynchronized API calls.
Installation
You can only install the extension with Swift Package Manager right now. Please add
into your
Package.swift
file. And then runswift package update
under command line.Usage
While working with KKBOX’s Open API Swift SDK, you may write code with nested callback handling like this:
Promises fix the callback hells. After adding the extension, you can make the code above like this:
License
Copyright 2018-2019 KKBOX Technologies Limited
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.