Created
December 26, 2009 15:59
-
-
Save chaliy/263972 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace TryRx | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Order.Paid.Subscribe(_ => Console.WriteLine("Paid")); | |
var order = new Order(); | |
order.MarkPaid(DateTime.Now); | |
order.MarkPaid(DateTime.Now); | |
} | |
public enum OrderStatus | |
{ | |
Pending, | |
Paid | |
} | |
public class Order | |
{ | |
private OrderStatus _status; | |
private DateTime? _paidDate; | |
private static readonly Subject<Order> PaidSubj = new Subject<Order>(); | |
public static IObservable<Order> Paid { get { return PaidSubj; } } | |
public void MarkPaid(DateTime paidDate) | |
{ | |
_paidDate = paidDate; | |
_status = OrderStatus.Paid; | |
PaidSubj.OnNext(this); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment