In my code below I get a face from the camera every second. If I recognize the user, I get a token. If I don't recognize the user, I print an error.
The problem is that I don't want to spam the user with errors every second. How can I print the error on the nth consecutive failure?
subscription = getFaces()
.throttleTime(1000)
.switchMap(face => {
return Observable.fromPromise(authenticateUserFace(face))
.catch(err => {
console.log('Not found') // I want this to happen after 3 consecutive attempts
// But I don't want to retry
// I want a new value from the outer observable
return Observable.empty()
})
})
.subscribe((token) => {
console.log('Found')
console.log(token)
})