Skip to content
Discussion options

You must be logged in to vote

I think it's something more like

import { joinURL } from 'ufo'
import { safeDestr } from 'destr'

export function useRealtimeQuery(events?: string | string[]) {
  const _events = events
    ? Array.isArray(events)
      ? events
      : [events]
    : undefined

  let resolve: null | (() => void), reject: null | ((error: any) => void)

  const queryPromise = new Promise<void>((res, rej) => {
    resolve = res
    reject = rej
  })

  const { event, data } = useEventSource(joinURL(useRequestURL().origin, '/api/test/event'), _events)
  const queryCache = useQueryCache()

  watch(data, (newData) => {
    // initial promise
    if (resolve) {
      resolve()
      resolve = null
    } else {

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
8 replies
@posva
Comment options

@posva
Comment options

@sandros94
Comment options

@posva
Comment options

Answer selected by posva
@sandros94
Comment options

@posva
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants