UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

30 lines (25 loc) 629 B
// TODO get proper type type Query = any export async function resolveZeroQuery(query: Query): Promise<any> { const view = query.materialize() // slow query warning const tm = setTimeout(() => { console.warn( ` Warning: query slow to resolve, ensure Zero server is running`, JSON.stringify(query.ast, null, 2) ) }, 2000) return new Promise((res, rej) => { try { const unsubscribe = view.addListener((snapshot) => { unsubscribe() clearTimeout(tm) res(snapshot) }) view.hydrate() } catch (err) { clearTimeout(tm) rej(err) } }) }