@@ -7,12 +7,13 @@ import type { RelatedCollection as ManyArray } from '@ember-data/store/-private'
7
7
import {
8
8
ARRAY_SIGNAL ,
9
9
entangleSignal ,
10
+ getOrCreateInternalSignal ,
10
11
notifyInternalSignal ,
12
+ OBJECT_SIGNAL ,
11
13
recordIdentifierFor ,
12
14
setRecordIdentifier ,
13
15
withSignalStore ,
14
16
} from '@ember-data/store/-private' ;
15
- import { getSignal , invalidateSignal , type Signal , Signals } from '@ember-data/tracking/-private' ;
16
17
import { DEBUG } from '@warp-drive/build-config/env' ;
17
18
import { assert } from '@warp-drive/build-config/macros' ;
18
19
import type { StableRecordIdentifier } from '@warp-drive/core-types' ;
@@ -47,18 +48,7 @@ const getLegacySupport = macroCondition(dependencySatisfies('@ember-data/model',
47
48
48
49
export { Editable , Legacy , Checkout } from './symbols' ;
49
50
const IgnoredGlobalFields = new Set < string > ( [ 'length' , 'nodeType' , 'then' , 'setInterval' , 'document' , STRUCTURED ] ) ;
50
- const symbolList = [
51
- Destroy ,
52
- RecordStore ,
53
- Identifier ,
54
- Editable ,
55
- Parent ,
56
- Checkout ,
57
- Legacy ,
58
- Signals ,
59
- EmbeddedPath ,
60
- EmbeddedType ,
61
- ] ;
51
+ const symbolList = [ Destroy , RecordStore , Identifier , Editable , Parent , Checkout , Legacy , EmbeddedPath , EmbeddedType ] ;
62
52
const RecordSymbols = new Set ( symbolList ) ;
63
53
64
54
type RecordSymbol = ( typeof symbolList ) [ number ] ;
@@ -89,7 +79,6 @@ export class SchemaRecord {
89
79
declare [ EmbeddedPath ] : string [ ] | null ;
90
80
declare [ Editable ] : boolean ;
91
81
declare [ Legacy ] : boolean ;
92
- declare [ Signals ] : Map < string , Signal > ;
93
82
declare [ Symbol . toStringTag ] : `SchemaRecord<${string } >`;
94
83
declare ___notifications : object ;
95
84
@@ -306,10 +295,7 @@ export class SchemaRecord {
306
295
// TODO pass actual cache value not {}
307
296
return schema . hashFn ( field ) ( { } , field . options ?? null , field . name ?? null ) ;
308
297
case '@local' : {
309
- // FIXME the signal is the local storage, don't need the double entangle
310
- const lastValue = computeLocal ( receiver , field , prop as string ) ;
311
- entangleSignal ( signals , receiver , prop as string , null ) ;
312
- return lastValue ;
298
+ return computeLocal ( receiver , field , prop as string ) ;
313
299
}
314
300
case 'field' :
315
301
entangleSignal ( signals , receiver , field . name , null ) ;
@@ -439,10 +425,15 @@ export class SchemaRecord {
439
425
return true ;
440
426
}
441
427
case '@local' : {
442
- const signal = getSignal ( receiver , prop as string , true ) ;
443
- if ( signal . lastValue !== value ) {
444
- signal . lastValue = value ;
445
- invalidateSignal ( signal ) ;
428
+ const signal = getOrCreateInternalSignal (
429
+ signals ,
430
+ receiver ,
431
+ prop as string | symbol ,
432
+ field . options ?. defaultValue ?? null
433
+ ) ;
434
+ if ( signal . value !== value ) {
435
+ signal . value = value ;
436
+ notifyInternalSignal ( signal ) ;
446
437
}
447
438
return true ;
448
439
}
@@ -615,7 +606,7 @@ export class SchemaRecord {
615
606
if ( identityField . name && identityField . kind === '@id' ) {
616
607
const signal = signals . get ( '@identity' ) ;
617
608
if ( signal ) {
618
- invalidateSignal ( signal ) ;
609
+ notifyInternalSignal ( signal ) ;
619
610
}
620
611
}
621
612
break ;
@@ -645,7 +636,7 @@ export class SchemaRecord {
645
636
// console.log(`Notification for ${key} on ${identifier.type}`, self);
646
637
const signal = signals . get ( key ) ;
647
638
if ( signal ) {
648
- invalidateSignal ( signal ) ;
639
+ notifyInternalSignal ( signal ) ;
649
640
}
650
641
const field = fields . get ( key ) ;
651
642
if ( field ?. kind === 'array' || field ?. kind === 'schema-array' ) {
@@ -656,16 +647,14 @@ export class SchemaRecord {
656
647
ARRAY_SIGNAL in peeked
657
648
) ;
658
649
const arrSignal = peeked [ ARRAY_SIGNAL ] ;
659
- arrSignal . isStale = true ;
660
- invalidateSignal ( arrSignal ) ;
650
+ notifyInternalSignal ( arrSignal ) ;
661
651
}
662
652
}
663
653
if ( field ?. kind === 'object' ) {
664
654
const peeked = peekManagedObject ( self , field ) ;
665
655
if ( peeked ) {
666
656
const objSignal = peeked [ OBJECT_SIGNAL ] ;
667
- objSignal . isStale = true ;
668
- invalidateSignal ( objSignal ) ;
657
+ notifyInternalSignal ( objSignal ) ;
669
658
}
670
659
}
671
660
}
@@ -685,7 +674,7 @@ export class SchemaRecord {
685
674
// console.log(`Notification for ${key} on ${identifier.type}`, self);
686
675
const signal = signals . get ( key ) ;
687
676
if ( signal ) {
688
- invalidateSignal ( signal ) ;
677
+ notifyInternalSignal ( signal ) ;
689
678
}
690
679
// FIXME
691
680
} else if ( field . kind === 'resource' ) {
@@ -721,7 +710,7 @@ export class SchemaRecord {
721
710
if ( field . options . async ) {
722
711
const signal = signals . get ( key ) ;
723
712
if ( signal ) {
724
- invalidateSignal ( signal ) ;
713
+ notifyInternalSignal ( signal ) ;
725
714
}
726
715
}
727
716
}
0 commit comments