mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-25 23:05:23 +00:00
wip
This commit is contained in:
@@ -2,25 +2,7 @@
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*/
|
||||
|
||||
let buffer: Array<any> = [];
|
||||
let galite: null | Function = null;
|
||||
let galitePromise: null | Promise<any> = null;
|
||||
// @ts-ignore
|
||||
import ga from 'ga-lite';
|
||||
|
||||
export function ga(...args: any[]): void {
|
||||
if (typeof galite === 'function') {
|
||||
galite.apply(null, args);
|
||||
return;
|
||||
}
|
||||
buffer.push(args);
|
||||
if (!galitePromise) {
|
||||
// @ts-ignore
|
||||
galitePromise = import('ga-lite').then((mod) => {
|
||||
galite = mod.default;
|
||||
galitePromise = null;
|
||||
buffer.forEach((args) => {
|
||||
mod.default.apply(null, args);
|
||||
});
|
||||
buffer = [];
|
||||
});
|
||||
}
|
||||
}
|
||||
export default ga;
|
||||
|
||||
Reference in New Issue
Block a user