0
// ticker$ will update every 3s
// showHand$ will only triger after user click button
// I would like to take last ticker price as user order price when user click button
let lastPrice: number;
this.ticker$
// What I am doing now is preserve value to vairable here.
.do(ticker => lastPrice = ticker.closePrice)
.switchMap(() => this.showHand$)
.subscribe(showHand => {
// use value here
this.order.price = lastPrice;
this.order.amount = showHand.amount;
this.order.type = showHand.type;
this.submit();
});
任何有關如何預先保存值和切換地圖的方法,沒有像上面那樣的一行變量?RxJS,Observable,如何保存值並將地圖切換到另一個
什麼需要(1)怎麼辦? –
take(n)限制showHand $的項目數量,並在n項目之後發出complete()。完成此應該會自動停止訂閱。 –