Guest User

Untitled

a guest
Oct 23rd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. public interface IService
  2. {
  3. Task<SessionModel> GetData(string id);
  4. }
  5.  
  6. /// Provides a group of schedulers available to be used
  7. public interface ISchedulers
  8. {
  9. IScheduler Default {get;}
  10. IScheduler Dispatcher {get;}
  11. }
  12.  
  13. public class MyVm
  14. {
  15. IService service;
  16.  
  17. public MyVm(ISchedulers schedulers, IService service)
  18. {
  19. this.service = service;
  20. this.session = this.WhenAnyValue(x => x.SessionId)
  21. .SelectMany(SearchSession)
  22. .ObserverOn(schedulers.Default)
  23. .ToProperty(this, x => x.Session);
  24. }
  25.  
  26. private async Task<SessionModel> SearchSession(string id)
  27. {
  28. return await this.service.GetData(id);
  29. }
  30. }
Add Comment
Please, Sign In to add comment