@cortical/core
Version:
A RESTful API framework for your apps based on GraphQL type system.
12 lines (11 loc) • 394 B
text/typescript
import { Subscriber } from '@cortical/core';
import { Context } from '../context';
export const subscribeMessage: Subscriber<string, void, Context> = async function* (args, context) {
context.end(() => {
context.debug('completed');
});
while (!context.completed) {
yield `Hello from WebSocket ${Math.random()}`;
await new Promise(resolve => setTimeout(resolve, 1000));
}
};