cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
               <script src="https://unpkg.com/@reactivex/rxjs/dist/global/Rx.js"></script>
            
          
!
            
              enum Action{
    buy = 'BUY',
    sell = 'SELL'
}

class Order{
    constructor(public orderId: number, public traderId: number, public stock: string, public shares: number, public action:Action){}
}

let traders: Rx.Subject<Trader> = new Rx.Subject<Trader>();

class Trader {

    orders: Rx.Subject<Order> = new Rx.Subject<Order>();

    constructor(private traderId:number, public traderName:string){}
}

let tradersSubscriber = traders.subscribe(trader => console.log(`Trader ${trader.traderName} arrived`))

let ordersSubscriber = traders
    .flatMap(trader => trader.orders)
    .subscribe(ord => console.log(`Got order from trader ${ord.traderId} to ${ord.action} ${ord.shares} shares of ${ord.stock}`));

let firstTrader = new Trader(1, 'Joe');
let secondTrader = new Trader(2, 'Mary');

traders.next(firstTrader);
traders.next(secondTrader);

let order1:Order = new Order(1, 1,'IBM',100,Action.buy);
let order2:Order = new Order(2, 1,'AAPL',200,Action.sell);
let order3:Order = new Order(3, 2,'MSFT',500,Action.buy);

firstTrader.orders.next( order1);
firstTrader.orders.next( order2);
secondTrader.orders.next( order3);
            
          
!
999px
Loading ..................

Console