Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promised based interface #163

Closed
simme opened this issue Jan 16, 2017 · 3 comments
Closed

Promised based interface #163

simme opened this issue Jan 16, 2017 · 3 comments
Labels

Comments

@simme
Copy link

simme commented Jan 16, 2017

Hello,

Have you considered adding a promise based interface? I realize that it might not be desirable to add additional dependencies to GRDB itself (a framework for promises) but maybe as an additional "add-on"?

It could be very nice when chaining operations. But mostly it would be a nice way of handling errors (IMO).

I realize it would be a pretty big job to wrap all methods to return promises and not something I expect to happen. Just curious if it's something you've even considered?

@groue
Copy link
Owner

groue commented Jan 16, 2017

Hello @simme

So far the synchronous approach has shown straightforward and efficient.

Users who need asynchronous behaviors can write asynchronous wrappers around the synchronous primitives if they want. That's what Swift extensions are for, and my recommendation.

I realize it would be a pretty big job to wrap all methods to return promises and not something I expect to happen. Just curious if it's something you've even considered?

Yes it is a big job, and yes it has already been considered (and rejected). I think that it's easier said than done, for benefits I don't buy. Asynchronous methods can't easily express the rethrows qualifier of synchronous methods, for example. We'd also need to introduce a Result type, in an already crowded landscape. And the synchronous approach is simpler. GRDB aims at being a welcoming library, not a flagship for some fashionable patterns. It welcomes fashion, of course: in your extensions.

Swift is evolving. Language support for asynchronous constructs is expected for Swift 4 or 5. Be patient, and polish your views of promises (or futures, or reactive programming, or channels, or whatever gives you the thrill) in the meantime. A synchronous GRDB blends into all of those patterns, and I'm quite happy with that.

@groue groue added the question label Jan 16, 2017
@simme
Copy link
Author

simme commented Jan 16, 2017

That makes a lot of sense and seems perfectly reasonable. I was looking through the issue history looking for questions re async but somehow missed that issue you linked to.

I was mostly curious. Thank you for taking the time to answer thoroughly and thank you for a fantastic database framework! :)

@simme simme closed this as completed Jan 16, 2017
@groue
Copy link
Owner

groue commented Jan 16, 2017

You're welcome @simme ! Happy GRDB ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants