From 11baf981ee6c087defc938b191b4992a8d8e7f90 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 27 Jun 2020 00:03:37 +0200 Subject: [PATCH] 0.2.3: implement awful hack to work around sveltejs/svelte#4899 Without this, unpredictable crashes may occur in seemingly random places. This will be reverted as soon as sveltejs/svelte#4909 is merged. --- CHANGELOG.md | 3 +++ package.js | 2 +- subscribe.js | 12 +++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a045403..13b7780 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.2.3 +- Implement hack to work around sveltejs/svelte#4899 + ## 0.2.2 - Support `Tracker.autorun()` inside `onMount()` diff --git a/package.js b/package.js index c65f07f..4a801f0 100644 --- a/package.js +++ b/package.js @@ -1,6 +1,6 @@ Package.describe({ name: 'rdb:svelte-meteor-data', - version: '0.2.2', + version: '0.2.3', summary: 'Reactively track Meteor data inside Svelte components', git: 'https://github.com/rdb/svelte-meteor-data', documentation: 'README.md' diff --git a/subscribe.js b/subscribe.js index 48c7ed1..47a095b 100644 --- a/subscribe.js +++ b/subscribe.js @@ -4,7 +4,17 @@ * - Makes the return value usable in {#await} blocks */ -import { current_component } from 'svelte/internal'; +import { current_component, set_current_component, tick } from 'svelte/internal'; + + +const promise = tick(); +const oldThen = promise.then; +promise.then = function (fn) { + oldThen.call(promise, () => { + fn(); + set_current_component(null); + }); +}; _subscribe = Meteor.subscribe; Meteor.subscribe = function subscribe(name) {