Comments (5)
The reason the callbacks are made in the main thread is that this library was written for cases where you need to import a (potentially) large CSV file and want to give the user some kind of progress feedback. That's what the onProgress and onFinish callbacks were designed for and since the UI should only be updated in the main thread, those blocks are called on the main thread.
I don't see any adverse effects except for the above mentioned UI changes when you would fork this and remove the main thread calls. If you want to ensure that you have an up-to-date framework, feel free to make your change in your fork additive (and non-breaking) so I can merge your changes via a Pull Request and we have optional support for explicitly defining the thread on which the callbacks should be called. I imagine something like this:
let importer = CSVImporter<[String]>(...)
importer.qosClass = .background
importer.startImporting(...).onProgress {
// called in background thread
}.onFinish {
// called in background thread
}
By default it would then still make the calls in the main thread, except for if you have defined a qosClass, then it would use a global DispatchQueue of the given qos class.
from csvimporter.
I think that's reasonable. I am importing a large CSV but I'd like to have all processing finished on the background thread where I import into my indexable data model. While I love your implementation I may end up rolling my own or using one of the other parsers. My need is slightly different than what you're addressing.
Thanks for getting back to me.
from csvimporter.
But the importing is done on a background thread and adding support for background threads in the callbacks is not a complex task, if you're not sure how to add that feature yourself I can do that. Others may need the feature, too.
from csvimporter.
I just implemented such a feature and released version 1.6.0 with it included. See the end of the Asynchronous with Callbacks section in the README for usage. Your requested behavior should now be possible @rodericj. If you have any more questions feel free to ask.
Closing this.
from csvimporter.
Note that I've also just added a synchronously working import method and released version 1.7.0 with it. Refer to the docs here.
from csvimporter.
Related Issues (20)
- Publish 1.9.0 to Cocoapods HOT 1
- Cannot init CSVImporter HOT 1
- Reporting parsing errors HOT 7
- Any way to get the column headers before parsing the rest? HOT 2
- Import CSV
- Different UTF encoding? HOT 1
- Swift Package Manager support broken HOT 2
- Traking progress via Progress Bar HOT 6
- Linux Support HOT 4
- Is it safe to assume that no more frameworks will be imported HOT 1
- Code Signing Fails in XCode 10 HOT 6
- Doesn't properly handle empty lines in the data HOT 1
- Remote URL formats? HOT 1
- trim whitespace from headers
- Add installation instructions for Accio & list as supported
- Reading the CSV while considering the columns and the headers? HOT 2
- Can't find CSVImporter.framework HOT 3
- Add Codable support HOT 2
- Add option for processing data in batches HOT 1
- 'Hashable.hashValue' is deprecated as a protocol requirement; conform type 'Regex' to 'Hashable' by implementing 'hash(into:)' instead HOT 2
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 csvimporter.