In a C # console application, using System.Reactive.Linq, I try to make observable, where each element is the string result of some processing by another observable. I created a simple image using strings and characters. Warning, this example is completely CONTROL, and the fact is that the nested .Wait () hangs.
class Program
{
static void Main(string[] args)
{
string[] fileNames = { "file1.doxc", "file2.xlsx", "file3.pptx" };
IObservable<string> files = fileNames.ToObservable();
string[] extensions = files.Select(fn =>
{
var extension = fn.ToObservable()
.TakeLast(4)
.ToArray()
.Wait();
return new string(extension);
})
.ToArray()
.Wait();
}
}
Again, this is not how I find the suffix of many file names. The question is, how can I create an Observable of strings where strings are computed from a completed observable.
If I pulled out this code and ran it alone, it will complete perfectly.
var extension = fn.ToObservable()
.TakeLast(4)
.ToArray()
.Wait();
There is something about the nested Wait () for async methods that I don't understand.
How can I encode nested async observables, so I can create a simple array of strings?
thank
-John