Comment

Comment by gloosx

The proper implementation looks kinda bulky to me. Are you not allowed to use promises? Feels more like a naive solution for anyone who has few months of experience with javascript or is it cheating?

  const PromiseQueue = {
    queue: Promise.resolve(true),
    sendOnce(request) {
      return new Promise((resolve, reject) => {
        this.queue = this.queue
          .then(request)
          .then(resolve)
          .catch(reject)
      })
    }
  }
parent gloosx 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton