@@ -4,7 +4,7 @@ import type { QueryClient } from './queryClient'
44import { notifyManager } from './notifyManager'
55import { Action , Mutation , MutationState } from './mutation'
66import { matchMutation , MutationFilters , noop } from './utils'
7- import { Notifiable } from './notifiable '
7+ import { Subscribable } from './subscribable '
88
99// TYPES
1010
@@ -61,9 +61,11 @@ type MutationCacheNotifyEvent =
6161 | NotifyEventMutationObserverRemoved
6262 | NotifyEventMutationUpdated
6363
64+ type MutationCacheListener = ( event : MutationCacheNotifyEvent ) => void
65+
6466// CLASS
6567
66- export class MutationCache extends Notifiable < MutationCacheNotifyEvent > {
68+ export class MutationCache extends Subscribable < MutationCacheListener > {
6769 config : MutationCacheConfig
6870
6971 private mutations : Mutation < any , any , any , any > [ ]
@@ -134,6 +136,14 @@ export class MutationCache extends Notifiable<MutationCacheNotifyEvent> {
134136 return this . mutations . filter ( mutation => matchMutation ( filters , mutation ) )
135137 }
136138
139+ notify ( event : MutationCacheNotifyEvent ) {
140+ notifyManager . batch ( ( ) => {
141+ this . listeners . forEach ( listener => {
142+ listener ( event )
143+ } )
144+ } )
145+ }
146+
137147 onFocus ( ) : void {
138148 this . resumePausedMutations ( )
139149 }
0 commit comments