INNER CODE UNIT · TypeScript

client

enisdenjo/graphql-sse · src/client.ts:331

  const client = (() => {
    let disposed = false;
    const listeners: (() => void)[] = [];
    return {
      get disposed() {
        return disposed;
      },
      onDispose(cb: () => void) {
        if (disposed) {
          // empty the call stack and then call the cb
          setTimeout(() => cb(), 0);
          return () => {
            // noop
          };
        }
        listeners.push(cb);
        return () => {
          listeners.splice(listeners.indexOf(cb), 1);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…