UNPKG

@tanstack/router-core

Version:

Modern and scalable routing for React applications

1 lines 728 B
{"version":3,"file":"batch.cjs","names":[],"sources":["../../../src/utils/batch.ts"],"sourcesContent":["import { batch as storeBatch } from '@tanstack/store'\n\nimport { isServer } from '@tanstack/router-core/isServer'\n\n// `@tanstack/store`'s `batch` is for reactive notification batching.\n// On the server we don't subscribe/render reactively, so a lightweight\n// implementation that just executes is enough.\nexport function batch<T>(fn: () => T): T {\n if (isServer) {\n return fn()\n }\n\n let result!: T\n storeBatch(() => {\n result = fn()\n })\n return result\n}\n"],"mappings":";;;;AAOA,SAAgB,MAAS,IAAgB;AACvC,KAAI,+BAAA,SACF,QAAO,IAAI;CAGb,IAAI;AACJ,EAAA,GAAA,gBAAA,aAAiB;AACf,WAAS,IAAI;GACb;AACF,QAAO"}