2

as the title says I want to extract the variable status to be able to use it in another part of the code, is this possible?

RNAudioStreamer.status((err, status)=>{if(!err) console.log(status)})
  • No. Put the other part of the code inside the callback (or call it from there, at least). – Bergi Aug 29 '17 at 02:43

1 Answers1

0

Depending on the callback sync/async you can create a global variable or use promise.

let p = new Promise((resolve, reject) => {
  RNAudioStreamer.status((err, status)=>{
    if(!err) resolve(status); else reject(err); 
  })      
});

// ...


p.then(status => {
  // process status here
})
Damask
  • 1,754
  • 1
  • 13
  • 24