I'm trying to use a tween as a counter that only returns 0-4 over a duration. I only want it to return a number of the same once. I'm using https://popmotion.io/. Here is what I have so far.
import { tween, easing, transform } from 'popmotion';
onHandleClick() {
// const { clamp } = transform;
const twn = tween({ from: 0, to: 4 }).pipe(Math.round);
twn.start(this.addToList);
}
addToList(val) {
console.log('val = ', val);
}
The above outputs the following:
val = 1
val = 1
val = 2
val = 2
val = 2
val = 3
val = 3
val = 3
val = 3
val = 3
val = 4
val = 4
val = 4
val = 4
val = 4
val = 4
val = 4
What I'm after is so it only outputs a unique number from 0 - 4 Example:
val = 0
val = 1
val = 2
val = 3
val = 4
They have a filter method that it says.
filter((v: any) => boolean): Returns a new action that filters out values when the provided function returns false.
I'm not sure how I would use the filter to only return the same number once ?