Skip to content

Commit

Permalink
Fix bug with destroying when register destructor (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer committed Nov 17, 2021
1 parent f151a25 commit 2c8f7e1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion addon/decorators/stateful-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { StatefulPromise } from 'ember-stateful-promise/utils/stateful-promise';
import { CanceledPromise } from 'ember-stateful-promise/utils/canceled-promise';
import { DestroyableCanceledPromise } from 'ember-stateful-promise/utils/destroyable-canceled-promise';
import { tracked } from '@glimmer/tracking';
import { registerDestructor } from '@ember/destroyable';
import { registerDestructor, isDestroying } from '@ember/destroyable';

const CANCEL_PROMISE = Symbol('cancele-promise');

Expand Down Expand Up @@ -75,6 +75,10 @@ export function statefulFunction(options) {
);
}

if (isDestroying(ctx)) {
return;
}

registerDestructor(ctx, () => {
handler.reset();
handler.performCount = 0;
Expand Down

0 comments on commit 2c8f7e1

Please sign in to comment.