| 848 | * @param mutations - Array of mutation objects to confirm |
| 849 | */ |
| 850 | const confirmOperationsSync = (mutations: Array<any>) => { |
| 851 | if (!syncParams) { |
| 852 | // Sync not initialized yet, mutations will be handled on next sync |
| 853 | return |
| 854 | } |
| 855 | |
| 856 | const { begin, write, commit } = syncParams |
| 857 | |
| 858 | // Write the mutations through sync to confirm them |
| 859 | begin() |
| 860 | mutations.forEach((mutation: any) => { |
| 861 | write({ |
| 862 | type: mutation.type, |
| 863 | value: |
| 864 | mutation.type === `delete` ? mutation.original : mutation.modified, |
| 865 | }) |
| 866 | }) |
| 867 | commit() |
| 868 | } |
| 869 | |
| 870 | return { |
| 871 | ...syncConfig, |