Skip to main content
1-Visitor
March 3, 2022
Solved

Full script stop

  • March 3, 2022
  • 2 replies
  • 1477 views

Hello, how can I implement a complete stop of the script so that, under some condition, the script is not interrupted, not paused, namely, it stops working (I take into account that the script is launched once, without using Autorefresh). The script is not cyclical, a full stop could happen at any moment of the script execution.

Best answer by PaiChung

What is the actual use case?

It is very rare that you would just 'stop' a script.

Often you would use if/then/else statements (perhaps with some properties to see which way execution should go)

or if you are doing a loop you would use 'break'

2 replies

PaiChung22-Sapphire IAnswer
22-Sapphire I
March 4, 2022

What is the actual use case?

It is very rare that you would just 'stop' a script.

Often you would use if/then/else statements (perhaps with some properties to see which way execution should go)

or if you are doing a loop you would use 'break'

15-Moonstone
March 7, 2022

You can use a self executing function to encapsule you whole service and then use a return statement to stop it whenever you want.

 

const result = (function() {
 // Your service code
})();

 Or if you prefer the arrow notation:

const result = (() => {
 // Your service code
})();