* Adds a mutation to the cache. * @internal * @param mutation - The mutation to add. If it has a `scope`, it is queued in that scope.
(mutation: Mutation<any, any, any, any>)
| 165 | * @param mutation - The mutation to add. If it has a `scope`, it is queued in that scope. |
| 166 | */ |
| 167 | add(mutation: Mutation<any, any, any, any>): void { |
| 168 | this.#mutations.add(mutation) |
| 169 | const scope = scopeFor(mutation) |
| 170 | if (typeof scope === 'string') { |
| 171 | const scopedMutations = this.#scopes.get(scope) |
| 172 | if (scopedMutations) { |
| 173 | scopedMutations.push(mutation) |
| 174 | } else { |
| 175 | this.#scopes.set(scope, [mutation]) |
| 176 | } |
| 177 | } |
| 178 | this.notify({ type: 'added', mutation }) |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * Removes a mutation from the cache. |