Skip to content

Instantly share code, notes, and snippets.

@chaliy
Created December 26, 2009 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chaliy/263972 to your computer and use it in GitHub Desktop.
Save chaliy/263972 to your computer and use it in GitHub Desktop.
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