Below is the code example. This is for addon panel.
The router promise does not get resolved from inside global listner, though it works with normal ajax requests.
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return new Ember.RSVP.Promise(function(resolve, reject) {
// This works
Ember.$.ajax({
url : "http://bla.com"
type: "POST"
}).then(function(response){
resolve(response);;
});
// This doesn't work
addon.port.on(url, function(status, response) {
resolve(response);
})
});
});
I read somewhere this can be handled with Ember.run.bind but couldn't get it to work.