0

Assuming I have the following function:

ifvisible.now("idle", function(){
            // Stop auto updating the live data
            if (this.activitySub)
            this.activitySub.unsubscribe();
            });

Since all the variables inside function() { } are not recognized, how I can import or use them inside the function (or in any other way)?

0

1 Answer 1

1

try this Arrow Functions, not tested but may work for you :-

ifvisible.now("idle", () => {
  ...your code...
});

by using Arrow Functions

  • You don't need to keep typing function
  • It lexically captures the meaning of this
  • It lexically captures the meaning of arguments

see also

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.