0

I have a form which has several fields one of them is called bucketfilter where user can of which bucket he would like to retrieve.So to get all changes to the filter i subscribe to the buckerfilter on change like

  this.massEmailForm.get('bucketfilter').valueChanges.subscribe(val => {
            console.log('Value of Bucket Filter Change')
         });

this works fine and triggers the change but in my case causes the event to be fired several times. So if user selects 2 or 3 it will fire 2 or 3 times as i guess the change is gradually and not an all in one. So the question is there a way to delay this onchange event so it is only called ones not multiple times.

1 Answer 1

1

If I understand you correct you need debounceTime. If the user change massEmailForm n-th times during time declared in the debounceTime operator you will have only the one (last) event in the stream.

this.massEmailForm.get('bucketfilter').valueChanges
  .pipe(debounceTime(/* ms */))
  .subscribe(val => {
    console.log('Value of Bucket Filter Change')
  });
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.