I have defined an interface in F#
type IConnect =
abstract Update: seq<DataType> -> Async<bool>
I would like other apps in the same appdomain to implement it so that I can call Update on any that implement the interface (I gather the implementations in an TinyIoC container). The return type Async<bool>
can indicate if the update succeeded or not without having to wait for it. And I can update the apps in parallel.
The other apps are written in c# and when I started to write a reference (mock) implementation I realised that this would require any implementer to use a FSharpAsync
type which is not very pretty.
So, how do I define the interface so that it is easy to implement in c# and keep the async aspects?
Use Task or perhaps IObservable. You can convert between async
workflows and Task<T>
quite easily and it is a simple type to work with in C# or most .Net languages.
type IConnect = abstract Update: seq<DataType> -> Task<bool>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With