Q
Q
QQ2014-06-15 21:09:30
Mozilla
QQ, 2014-06-15 21:09:30

How to make a return to an external function in JS?

Good evening.
I get a callback function and I need to display the result in the storage() function.

function storage(name) {
// ...
    self.port.on("localeEmit", function(title) {
        return title;
    });
// ...
}

storage("title");

UPD: None

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vyacheslav Slinko, 2014-06-16
@botaniQQQ

function storage(name, callback) {
// ...
    self.port.on("localeEmit", function(title) {
        callback(title);
    });
// ...
}

storage("title", function(title) {
  //...
});

A
Alexey Svirschevskiy, 2014-06-15
@rezzet

So?

M
Mikhail Osher, 2014-06-16
@miraage

Alternatively, use Deferred/Promise .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question