Comments (1)
Hi @jeadev!
Sorry for the long delay. If this is still relevant to you, I created a small example of how you can parse the records from a table in your Airtable base.
The package uses Combine as its interface for returning the status of operations performed (create, delete) or the data requested (list, get). Given that Combine is a new framework, let's say you're using closures instead of Combine on your application.
I'm considering you have a class to encapsulate communication with Airtable. You can do something like the following:
import Combine
import AirtableKit
class Service {
private let airtable = Airtable(baseID: "<your base id>", apiKey: "<your API key>")
private var subscriptions: [AnyCancellable] = []
func listStudents(completion: @escaping (Result<[[String]], Error>) -> Void) {
airtable.list(tableName: "<your table name>")
.sink { completionEvent in
switch completionEvent {
case .finished:
// you can ignore this
print("successfully finished")
case .failure(let error):
print("got error \(error)")
completion(.failure(error))
}
} receiveValue: { records in
print("records \(records)")
let content = records.map { record -> [String] in
// map your record/row here
var result = [String]()
if let name = record.fields["Name"] as? String {
result.append(name)
}
if let logo = record.attachments["Picture"]?.first {
let logoUrl = logo.url.absoluteString
let logoSize = logo.metadata["size"] as? Int ?? 0
result.append(logoUrl)
result.append("\(logoSize)")
}
return result
}
completion(.success(content))
}
.store(in: &subscriptions)
}
}
Now to use it on your app:
let service = Service()
func getDataFromAirtable() {
service.listStudents { result in
switch result {
case .success(let rows):
// do something with rows
print("result: success \(rows)")
case .failure(let error):
// handle this as you wish
print("result: error \(error)")
}
}
}
I haven't written SpriteKit code for some time now, but I think you can use this as a starting point to implement what you need.
I'll close this for now, but feel free to comment and I'll see how I can help.
from airtablekit.
Related Issues (20)
- Adding 'Delete' function to public API.
- Add README to project
- Unit tests for facade methods
- Supporting `dynamicMemberLookup
- Property wrapper for SwiftUI interface?
- Use Github wiki HOT 1
- 'Batching' operations
- Fix Example project to use final version of the Framework
- Change single-element `delete` method to be similar to the batch version.
- Offsets/more than 100 rows HOT 3
- Allow filterByFormula searches HOT 1
- Can AirtableKit handle "filterByFormula" or "View" HOT 1
- Doesn't seem to be updating table? HOT 1
- Abstracing 'Patch' and 'Put' in a single 'Update' function HOT 1
- How to retrieve values from list method? HOT 2
- Airtable API keys will be deprecated by the end of January 2024 HOT 1
- Make Record and Attachment more flexible
- Add Apple-like documentation HOT 1
- Create an 'Example' iOS App
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from airtablekit.