File tree Expand file tree Collapse file tree 2 files changed +19
-18
lines changed
packages/angular-query-experimental/src Expand file tree Collapse file tree 2 files changed +19
-18
lines changed Original file line number Diff line number Diff line change @@ -131,9 +131,17 @@ describe('injectMutation', () => {
131131
132132 mutation . mutate ( 'xyz' )
133133
134- const mutations = mutationCache . find ( { mutationKey : [ '2' ] } )
134+ mutationKey . set ( [ '3' ] )
135135
136- expect ( mutations ?. options . mutationKey ) . toEqual ( [ '2' ] )
136+ mutation . mutate ( 'xyz' )
137+
138+ expect ( mutationCache . find ( { mutationKey : [ '1' ] } ) ) . toBeUndefined ( )
139+ expect (
140+ mutationCache . find ( { mutationKey : [ '2' ] } ) ?. options . mutationKey ,
141+ ) . toEqual ( [ '2' ] )
142+ expect (
143+ mutationCache . find ( { mutationKey : [ '3' ] } ) ?. options . mutationKey ,
144+ ) . toEqual ( [ '3' ] )
137145 } )
138146
139147 test ( 'should reset state after invoking mutation.reset' , async ( ) => {
Original file line number Diff line number Diff line change 44 NgZone ,
55 assertInInjectionContext ,
66 computed ,
7- effect ,
87 inject ,
98 signal ,
109 untracked ,
@@ -71,7 +70,15 @@ export function injectMutation<
7170 null
7271
7372 return computed ( ( ) => {
74- return ( instance ||= new MutationObserver ( queryClient , optionsSignal ( ) ) )
73+ const observerOptions = optionsSignal ( )
74+ return untracked ( ( ) => {
75+ if ( instance ) {
76+ instance . setOptions ( observerOptions )
77+ } else {
78+ instance = new MutationObserver ( queryClient , observerOptions )
79+ }
80+ return instance
81+ } )
7582 } )
7683 } ) ( )
7784
@@ -125,20 +132,6 @@ export function injectMutation<
125132 return observer . getCurrentResult ( )
126133 } )
127134
128- effect (
129- ( ) => {
130- const observer = observerSignal ( )
131- const observerOptions = optionsSignal ( )
132-
133- untracked ( ( ) => {
134- observer . setOptions ( observerOptions )
135- } )
136- } ,
137- {
138- injector,
139- } ,
140- )
141-
142135 const resultSignal = computed ( ( ) => {
143136 const resultFromSubscriber = resultFromSubscriberSignal ( )
144137 const resultFromInitialOptions = resultFromInitialOptionsSignal ( )
You can’t perform that action at this time.
0 commit comments