11import { DEBUG } from '@glimmer/env' ;
22
3- const DESTROYING = new WeakMap < GlimmerComponent < object > , boolean > ( ) ;
4- const DESTROYED = new WeakMap < GlimmerComponent < object > , boolean > ( ) ;
5-
6- export function setDestroying ( component : GlimmerComponent < object > ) : void {
7- DESTROYING . set ( component , true ) ;
8- }
9- export function setDestroyed ( component : GlimmerComponent < object > ) : void {
10- DESTROYED . set ( component , true ) ;
11- }
3+ export const IS_DESTROYING_KEY = Symbol ( '__is_destroying__' ) ;
4+ export const IS_DESTROYED_KEY = Symbol ( '__is_destroyed__' ) ;
125
136// This provides a type-safe `WeakMap`: the getter and setter link the key to a
147// specific value. This is how `WeakMap`s actually behave, but the TS type
@@ -224,6 +217,9 @@ export type Args<S> = ExpandSignature<S>['Args']['Named'];
224217 * inside the component `this.args.firstName` would also be `Tom`.
225218 */
226219export default class GlimmerComponent < S = unknown > {
220+ [ IS_DESTROYING_KEY ] = false ;
221+ [ IS_DESTROYED_KEY ] = false ;
222+
227223 /**
228224 * Constructs a new component and assigns itself the passed properties. You
229225 * should not construct new components yourself. Instead, Glimmer will
@@ -240,9 +236,6 @@ export default class GlimmerComponent<S = unknown> {
240236 }
241237
242238 this . args = args ;
243-
244- DESTROYING . set ( this , false ) ;
245- DESTROYED . set ( this , false ) ;
246239 }
247240
248241 /**
@@ -272,11 +265,11 @@ export default class GlimmerComponent<S = unknown> {
272265 readonly args : Readonly < Args < S > > ;
273266
274267 get isDestroying ( ) : boolean {
275- return DESTROYING . get ( this ) || false ;
268+ return this [ IS_DESTROYING_KEY ] || false ;
276269 }
277270
278271 get isDestroyed ( ) : boolean {
279- return DESTROYED . get ( this ) || false ;
272+ return this [ IS_DESTROYED_KEY ] || false ;
280273 }
281274
282275 /**
0 commit comments