mirror of
https://github.com/vale981/grapher
synced 2025-03-04 09:01:40 -05:00
Add .stop hook.
This commit is contained in:
parent
43008c63a2
commit
358c4f0211
1 changed files with 18 additions and 1 deletions
|
@ -21,10 +21,27 @@ export default class extends Base {
|
|||
throw new Meteor.Error('not-allowed', `You cannot subscribe to a resolver query`);
|
||||
}
|
||||
|
||||
let options = {};
|
||||
|
||||
if(typeof callback === 'function') {
|
||||
options.onReady = callback;
|
||||
} else if(callback && callback.onReady || callback.onStop) {
|
||||
options = callback;
|
||||
}
|
||||
|
||||
// integrate the onStop hook
|
||||
const oldStop = options.onStop;
|
||||
options.onStop = (...args) => {
|
||||
this.subscriptionHandle = null;
|
||||
|
||||
if(oldStop) {
|
||||
oldStop.apply(this, args);
|
||||
}
|
||||
};
|
||||
this.subscriptionHandle = subscriptionContext.subscribe(
|
||||
this.name,
|
||||
this.params,
|
||||
callback
|
||||
options
|
||||
);
|
||||
|
||||
return this.subscriptionHandle;
|
||||
|
|
Loading…
Add table
Reference in a new issue