Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function resubscribe(unknown, _extraneous) {
try {
const changed = add(query, unknown);
// console.log('Resubscribe');
if (!changed) return;
if (upstream) upstream.return(); // Close the existing stream.
upstream = store.call('watch', query, { skipFill: true });
let { value } = await upstream.next();
// console.log('Got first subscription value', value && debug(value));
if (typeof value === 'undefined') {
// The upstream is a change subscription, not a live query,
// so we need to fetch the initial value.
// TODO: Get a version corresponding to the subscription's start
// and verify that the store.read response is newer.