|
|
@@ -43,6 +43,8 @@ export default class DeltaReplayer {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Applies all deltas with delay between actions.
|
|
|
+ *
|
|
|
* @param {Number} timeInterval
|
|
|
*/
|
|
|
play( timeInterval = 1000 ) {
|
|
|
@@ -56,6 +58,29 @@ export default class DeltaReplayer {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * @param {Number} numberOfDeltas Number of deltas to apply.
|
|
|
+ * @returns {Promise}
|
|
|
+ */
|
|
|
+ applyDeltas( numberOfDeltas ) {
|
|
|
+ if ( numberOfDeltas <= 0 ) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.applyNextDelta()
|
|
|
+ .then( () => this.applyDeltas( numberOfDeltas - 1 ) )
|
|
|
+ .catch( err => console.warn( err ) );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @returns {Promise}
|
|
|
+ */
|
|
|
+ applyAllDeltas() {
|
|
|
+ return this.applyNextDelta()
|
|
|
+ .then( () => this.applyAllDeltas() )
|
|
|
+ .catch( err => console.warn( err ) );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* @returns {Promise}
|
|
|
*/
|
|
|
applyNextDelta() {
|
|
|
@@ -80,13 +105,4 @@ export default class DeltaReplayer {
|
|
|
} );
|
|
|
} );
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * @returns {Promise}
|
|
|
- */
|
|
|
- applyAllDeltas() {
|
|
|
- return this.applyNextDelta()
|
|
|
- .then( () => this.applyAllDeltas() )
|
|
|
- .catch( err => console.warn( err ) );
|
|
|
- }
|
|
|
}
|