0

I am using settimeout to run some code after a specific delay. However I want to add additional delay inside the settimeout block between two lines of code. I tried by using delay() but it is not working. How can I do this? Thanks in advance for your help?

My code:

setTimeout(() => {
      this.messageService.add({
        severity: 'success', summary: 'Yay',
        detail: 'Successfully done'
      });
      console.log('here1');
      delay(1000);
      console.log('here2'); // run this after delay


    }, 1500);
    

1 Answer 1

1

Try this:

setTimeout(() => {
      this.messageService.add({
        severity: 'success', summary: 'Yay',
        detail: 'Successfully done'
      });
      console.log('here1');
      
      setTimeout(() => {
        console.log('here2'); // run this after delay
      }, 1500);


    }, 1500);

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.