Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service Args Observable Must Be Hot #35

Open
RxDave opened this issue Jan 9, 2019 · 0 comments
Open

Service Args Observable Must Be Hot #35

RxDave opened this issue Jan 9, 2019 · 0 comments

Comments

@RxDave
Copy link
Owner

RxDave commented Jan 9, 2019

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(….);
@RxDave RxDave self-assigned this Jan 9, 2019
@RxDave RxDave pinned this issue Jan 9, 2019
@RxDave RxDave removed their assignment Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant