Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

end of subscription rerenders current page #70

Open
dpatte opened this issue Oct 11, 2021 · 4 comments
Open

end of subscription rerenders current page #70

dpatte opened this issue Oct 11, 2021 · 4 comments

Comments

@dpatte
Copy link

dpatte commented Oct 11, 2021

First, I want to say that I love this package and use it all my projects. Combined with PublishComposite, it has made a significant improvement to the performance of my projects.

But I noticed today that whenever any subs-cache subscription expires, the current template gets rerendered.

In my case, after a template is rendered, I do a scroll to top, and call an unveil function. I noticed after visiting several paths, then waiting for a backlog of subs-cache subscriptions to expire, that my current page was rescrolled to the top as each subs-cache expired.

I am wondering why the current template is rerendered, as presumably it already has all the data it needs from its own template subscriptions.

Is there a way to disable the rerenders triggered by the subs-cache subscription expiries? Or, perhaps can you suggest a way I can detect that the template has already been previously rendered and i can bypass my scroll-to-top function?

Thanks

@jankapunkt
Copy link
Contributor

Hi @dpatte can you provide a very short code example? You can always subscribe within Tracker.nonReactive in order to avoid recomputations, based on subscription handle reactivity. However, I don't know if that's the case in your code.

@dpatte
Copy link
Author

dpatte commented Oct 11, 2021

Hi. I''ll think of how I might produce a code sample.

But I did try this in my client setup code

subscriptionCache = new SubsCache(Meteor.isProduction? 5:1, -1); // 5 or 1 minutes, no limit of caches
Tracker.nonreactive(subscriptionCache.subscribe);

and still have the issue.

In my original issue, I go to page A (which sets up its own subscription), then go to page B (which also sets up its own subscription), then wait on page B for the first subscription to time-out. When the subscription for page A times out, B rerenders. Note that the two subscriptions are similar but subscribe to different data from a single collection.

I also don't want to lose reactivity from page B's subscription while I'm on page B. But its own data in this scenario doesn't change anyway.

@dpatte
Copy link
Author

dpatte commented Oct 11, 2021

I understand that in my scenario, the expiry of subscription A changes the content of minimongo triggering the rerender, but it doesn't change what data will be displayed on page B (because what I need for page B, is fully specified in subscription B).

From what I understand, this will always be the case, and a rerender caused from the expiry of an older subscription, in itself, should never cause a change to the contents of the current page. But as subs-cache currently stands, it does.

@dpatte
Copy link
Author

dpatte commented Nov 13, 2021

i have gotten around the issue by changing what i do in onRendered. When any older subscache expires, subscache still causes a full rerender the complete current page (though in my case it never really needs to), but my logic to scrollToTop is now handled elsewhere, which gets around the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants