public void Sample() { new ErrorProcessor(); new MyMessageProcessor(); Observable .Generate(0, x => x < 100, x => x + 1, x => new MyMessage { IsFirst = x % 2 == 0, IsSecond = x % 2 != 0, Reason = x.ToString() }) .Subscribe(x => MessageStream.GetMain().Send(x)); }
public MyMessageProcessor() : base(MessageStream.GetMain()) { OnReceive <MyMessage>(messages => messages .Where(message => message.IsSecond) .Do(message => WhenIsSecond(message))); OnReceive <MyMessage>(messages => messages .Where(message => message.IsFirst) .Do(message => WhenIsFirst(message))); }
public ErrorProcessor() : base(MessageStream.GetMain()) { OnReceive <ErrorMessage>(messages => messages.Do(message => Debug.WriteLine(message.Exception.Message + " : " + message.Message))); }