Observable Channels Extension
This extension layers support for IObserver over the current channels api. This gives the ability to leverage the RX framework and apply RX operators to streams of messages being received over a channel.
To use the extenstion you will firstly need to reference the OpenFin.Net.Adapter.Extensions.Observable package from NuGet.
You will then need to activate the extension as part of the runtime builder process by adding the UseObservableChannels call.
IRuntime runtime = new RuntimeFactory()
.UseObservableChannels()
.GetRuntimeInstance(new RuntimeOptions
{
Version = "stable",
UUID = "your-uuid",
LicenseKey = "your-license-key"
});
To access the api you should query the runtime for IObservableChannels.
For example
// Ask for the observable channels api
var channels = runtime.GetService<IObservableChannels>();
// Create an observable client
IObservableChannelClient client = observableChannels.CreateClient("test-provider");
await client.ConnectAsync();
// Register topic returns an IObservable instance
var unsubscriber = client.RegisterTopic<string>("your-topic")
.Throttle( Timespan.FromSeconds( 2 ) )
.Subscribe((payload) =>
{
Debug.WriteLine(payload);
});