Currently, if you use the QbservableServer.Create method to accept arguments, the IObservable<TSource> that is supposed to represents all clients' arguments is actually just a singleton observable that is instantiated once for each client. This defies intuition and restricts important scenarios regarding static vs. published service implementations.
For example, the following wouldn't work as expected since the function that is passed strings will actually be invoked once for each connected client. The strings observable is actually Observable.Return(...args…), for each connected client. Instead, it should be a hot observable that actually pushes all connected clients' arguments, thus service authors could use the Publish operator to construct singleton service instances.
TcpQbservableServer.Create<string, QueryContext>(…, …,
strings => (from name in strings select new User(name))
.Publish( // this isn't what you'd think - the publish function will be called once for each client
users => { // users isn't what you'd think - it only contains a single user, per invocation
var singleton1 = new MyService1(); // Bad assumption - instance is created for each client
var singleton2 = new MyService2(users); // Bad assumption - instance is created for each client
return from user in users
select new QueryContext( // QueryContext created per user - works as expected
singleton1,
singleton2,
user);
}))
.Subscribe(….);
Currently, if you use the
QbservableServer.Create
method to accept arguments, theIObservable<TSource>
that is supposed to represents all clients' arguments is actually just a singleton observable that is instantiated once for each client. This defies intuition and restricts important scenarios regarding static vs. published service implementations.For example, the following wouldn't work as expected since the function that is passed
strings
will actually be invoked once for each connected client. Thestrings
observable is actuallyObservable.Return(...args…)
, for each connected client. Instead, it should be a hot observable that actually pushes all connected clients' arguments, thus service authors could use thePublish
operator to construct singleton service instances.