type Call = { type: string; payload?: any };
const q: Call[] = [];
export function enqueue(call: Call) {
  q.push(call);
}
export async function flush(ctx: any) {
  while (q.length) {
    const c = q.shift()!;
    switch (c.type) {
      case 'PIN_INSIGHT':
        ctx?.pin?.(c.payload?.insight);
        break;
      default:
        break;
    }
  }
}
