Repository: trpc/trpc
File: packages/client/src/links/httpSubscriptionLink.ts (TypeScript)

Code before:
                const recreateOnErrorOpts = createRecreateOnErrorOpts(ev);

                const shouldRestart = await opts.shouldRecreateOnError(
                  recreateOnErrorOpts,
                );

                if (!shouldRestart) {
                  return false;
                }

                eventSource.restart(
                  getUrl({
                    transformer,
                    url: await urlWithConnectionParams(opts),
                    input,
                    path,
                    type,
                    signal: null,
                  }),
                  await resultOf(opts.eventSourceOptions),
                );

                return true;
              }

              return false;
            },
          });

          for await (const chunk of iterable) {
            if (!chunk.ok) {
              // TODO: handle in https://github.com/trpc/trpc/issues/5871
              continue;
            }
            const chunkData = chunk.data;

            // if the `tracked()`-helper is used, we always have an `id` field
            const data = 'id' in chunkData ? chunkData : chunkData.data;
            observer.next({
              result: {
                data,
              },
            });
          }

          observer.next({
            result: {
              type: 'stopped',
            },
          });
          observer.complete();

Review comment (suggestion):
make the `return false` more eagerly 

```ts
if (!x) {
  return false;
}

// [... 100 lines of code]

if (y) {
  return false;
}
// [... 100 lines of code]
return true;
```
is nicer to read than


```ts
if (x) {
  // [... 100 lines of code]

  if (y) {
    return false;
  }
    // [... 100 lines of code]
  return true;
}
return false;
```

it'll remove one level of nesting in this here

Code after:
                return false;
              }

              const recreateOnErrorOpts = createRecreateOnErrorOpts(ev);

              const shouldRestart = await opts.shouldRecreateOnError(
                recreateOnErrorOpts,
              );

              if (!shouldRestart) {
                return false;
              }

              eventSource.restart(
                getUrl({
                  transformer,
                  url: await urlWithConnectionParams(opts),
                  input,
                  path,
                  type,
                  signal: null,
                }),
                await resultOf(opts.eventSourceOptions),
              );

              return true;
            },
          });

          for await (const chunk of iterable) {
            if (!chunk.ok) {
              // TODO: handle in https://github.com/trpc/trpc/issues/5871
              continue;
            }
            const chunkData = chunk.data;

            // if the `tracked()`-helper is used, we always have an `id` field
            const data = 'id' in chunkData ? chunkData : chunkData.data;
            observer.next({
              result: {
                data,
              },
            });
          }

          observer.next({
            result: {
              type: 'stopped',
            },
          });
          observer.complete();