S
S
Sland Show2019-02-02 14:22:56
typescript
Sland Show, 2019-02-02 14:22:56

Scope inside lambda functions (callbacks)?

I have Observable callback.

this.clientService.checkConnectionToONT(this.tan).subscribe(
      response => {
        this.etcdService.waitOntRegistrationEvents(response).subscribe(
          registrationEvent => {
             if (response.body === OntState.Online) 
                 this.disableDuringCall = false;
          });
       ...

And my question is this. Inside response there is a registrationEvent lambda. Is response available inside registrationEvent? Can I access it as described above?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2019-02-02
@Xuxicheta

Why not open the debugger yourself and take a look?
Answer: response will get into the closure of your inner function and will be visible.
And do not tear off the parameter like that. Write

this.clientService.checkConnectionToONT(this.tan)
  .subscribe((response) => {
    .....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question