Skip to content

Commit

Permalink
fix(server): No need to bind this scope
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo committed Oct 22, 2020
1 parent 9bb6d05 commit f76ac73
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/server.ts
Expand Up @@ -34,7 +34,6 @@ import {
isAsyncIterable,
hasOwnObjectProperty,
hasOwnStringProperty,
noop,
} from './utils';
import { ID } from './types';

Expand Down Expand Up @@ -324,7 +323,7 @@ export function createServer(

Object.entries(ctxRef.current.subscriptions).forEach(
([, subscription]) => {
(subscription.return || noop)();
subscription.return?.();
},
);
}
Expand Down Expand Up @@ -544,7 +543,7 @@ export function createServer(
}
case MessageType.Complete: {
if (ctx.subscriptions[message.id]) {
await (ctx.subscriptions[message.id].return ?? noop)();
await ctx.subscriptions[message.id].return?.();
}
break;
}
Expand Down
6 changes: 5 additions & 1 deletion src/tests/client.ts
Expand Up @@ -6,7 +6,11 @@ import WebSocket from 'ws';
import { url, startServer, pubsub } from './fixtures/simple';
import { Server } from '../server';
import { createClient, EventListener } from '../client';
import { noop } from '../utils';

// Just does nothing
export function noop(): void {
/**/
}

/** Waits for the specified timeout and then resolves the promise. */
const wait = (timeout: number) =>
Expand Down
4 changes: 0 additions & 4 deletions src/utils.ts
Expand Up @@ -51,7 +51,3 @@ export function hasOwnStringProperty<
typeof obj[prop] === 'string'
);
}

export function noop(): void {
/**/
}

0 comments on commit f76ac73

Please sign in to comment.