BehaviorSubjectを使用して、更新を一時停止して再開するバルブを作成します。バルブが閉じられたときに到着する更新については、dataUpdates
に背圧サポート(すなわち、バッファリング)が必要になることに注意してください。だから、擬似コードで
(私はコードswitftをしないので、私の構文を言い訳)
// create a BehaviorSubject with default value true. It will always emit
// the latest value when subscribed to, thus it is kind of a variable
let valve = BehaviorSubject(value: true)
// we are only interested to get one `true` value. When the latest value
// received by the valve is `true`, this will give a value immediately when
// subscribed to. When the latest value is `false`, this will not give
// any events until it is true.
let openValve = valve.filter{$0}.take(1)
// for each data update, pass it through if the valve is open and otherwise
// start waiting for it to turn true
let pauseableDataUpdates = dataUpdates.concatMap{update in openValve.map { _ in update}}
// now when you start rendering, you do
valve.on(.Next(false))
// and after animation is done, you do
valve.on(.Next(true))
この質問は古いですが、多分あなたはまだそれに答えを見つけることができます。 Observableが(特定の閾値を超えて排出量を下げる以外の方法で)バックプレッシャーをサポートしていない限り、その観測に入ることから排出を単に止めることはできません。リアクションプログラミングは、プル機構)。 – MatBos
私の問題を解決した 'subscribeNextAndWait'を実装しました。 –