INNER CODE UNIT · TypeScript

direction

maticzav/swift-graphql · server/src/resolvers.ts:62

        const direction = from > to ? -1 : 1
        for (let i = from; i != to; i += direction) {
          await new Promise((resolve) => setTimeout(resolve, 500))
          yield { count: i }
        }
      },
    },
    secret: {
      // This will return the value on every 1 sec until it reaches 0
      subscribe: async function* (_, { from }, ctx) {
        if (!ctx.user) {
          throw new AuthError()
        }

        for (let i = from; i >= 0; i -= 2) {
          await new Promise((resolve) => setTimeout(resolve, 500))
          yield { secret: i }
        }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…