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()。完成此应该会自动停止订阅。 –