pksprojects / ElasticSwift

Elasticsearch client in swift
MIT License
46 stars 18 forks source link

Have you considered using Futures instead of callbacks? #91

Open cshadek opened 3 years ago

cshadek commented 3 years ago

This would be similar to how Fluent works in Vapor and avoid callbacks.

I could see something along these lines:

return client.query().set(indices: ...).set(types: ...).search().map {
       // Code
}

Where .search() returns an EventLoopFuture<SearchResponse<T: Codable>>

It would make the code much more concise (Swifty 😉) and would fit better with packages like Vapor and Soto.

prafsoni commented 3 years ago

Having a functional API is something I have been wanting to add for so long but unfortunately, the Swift echo system doesn't have a standard functional API. I do have plans to add functional API based on Combine/OpenCombine in the future (probably after 1.0).