Skip to content

Commit

Permalink
Don't immediately resolve.
Browse files Browse the repository at this point in the history
  • Loading branch information
henrywalton committed Feb 23, 2021
1 parent a0886fb commit 86f391e
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions addon/services/apollo.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,30 +251,27 @@ export default class ApolloService extends Service {

const obj = new EmberApolloSubscription();

return waitForPromise(
new RSVP.Promise((resolve, reject) => {
let subscription = observable.subscribe({
next: (newData) => {
let dataToSend = extractNewData(resultKey, newData);
if (dataToSend === null) {
// see comment in extractNewData
return;
}

run(() => obj._onNewData(dataToSend));
},
error(e) {
return new RSVP.Promise((resolve, reject) => {
let subscription = observable.subscribe({
next: (newData) => {
let dataToSend = extractNewData(resultKey, newData);
if (dataToSend === null) {
// see comment in extractNewData
return;
}

run(() => obj._onNewData(dataToSend));
resolve(obj);
},
error(e) {
reject(e);
},
});

obj._apolloClientSubscription = subscription;

resolve(obj);
})
);
});
}


/**
* Executes a single `query` on the Apollo client. The resolved object will
* never be updated and does not have to be unsubscribed.
Expand Down

0 comments on commit 86f391e

Please sign in to comment.