import { Subject } from 'rxjs/Subject' ; enum Action { buy = 'BUY' , sell = 'SELL' } class Order { constructor ( public orderId , public traderId , public stock , public shares , public action ) { } } let orders = new Subject < Order > ( ) ; class Trader { constructor ( private traderId , private traderName ) { } placeOrder ( order ) { orders . next ( order ) ; } } let subscriber1 = orders . subscribe ( ord => console . log ( `Subscriber 1 got order to ${ ord . action } ${ ord . shares } shares of ${ ord . stock }` ) ) ; let subscriber2 = orders . subscribe ( ord => console . log ( `Subscriber 2 got order to ${ ord . action } ${ ord . shares } shares of ${ ord . stock }` ) ) ; let trader = new Trader ( 1 , 'Joe' ) ; let order1 = new Order ( 1 , 1 , 'IBM' , 100 , Action . buy ) ; let order2 = new Order ( 2 , 1 , 'AAPL' , 100 , Action . sell ) ; trader . placeOrder ( order1 ) ; subscriber2 . unsubscribe ( ) ; trader . placeOrder ( order2 ) ;