Consider the following
I have a method that call external library Lib.
Next, I would like to introduce a Future which wrap this call to be compatible with Combine.
What is a proper ("Combinish") way to dispatch Invocation.findBy on a given thread/queue?
I would like to dispatch this method on background thread, however, it is too expensive if I call it many times.
Also if I have many Combine modifiers , the call to this method is delayed, correct? But I would like to dispatch invocation on different queue/thread as soon as possible.
.subscribe(on: Scheduler) modifier doesn't change the execution queue/thread of body of future Service.findBy.
I have a method that call external library Lib.
Code Block enum Service { enum Invocation { static func findBy(id: String) -> Data? { Lib.FindById(id) } } }
Next, I would like to introduce a Future which wrap this call to be compatible with Combine.
Code Block extension Service { static func findBy(id: String) -> Future<Data?, Never> { .init { promise in promise(Invocation.findBy(id: id)) } } }
What is a proper ("Combinish") way to dispatch Invocation.findBy on a given thread/queue?
I would like to dispatch this method on background thread, however, it is too expensive if I call it many times.
Also if I have many Combine modifiers , the call to this method is delayed, correct? But I would like to dispatch invocation on different queue/thread as soon as possible.
.subscribe(on: Scheduler) modifier doesn't change the execution queue/thread of body of future Service.findBy.