Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Routes should unsubscribe from the page store before $page.params are updated #633

Closed
tony-sull opened this issue Apr 26, 2019 · 2 comments · Fixed by #1165
Closed

Routes should unsubscribe from the page store before $page.params are updated #633

tony-sull opened this issue Apr 26, 2019 · 2 comments · Fixed by #1165
Labels

Comments

@tony-sull
Copy link

Expected Behavior

A route autosubscribing to $page.params will be unsubscribed before $page.params is changed to a new route

Actual Behavior

The autosubscription is being triggered late exactly once, i.e. if I navigate from channels/[slug].svelte to games/[slug].svelte, the Channel route's subscription will be triggered exactly once with the slug param for the Game route

@maxdhn
Copy link

maxdhn commented Oct 17, 2019

I'm facing the same issue, I also tried to unsubscribe in onDestroy hook but it's trigger too late. Have you find a workaround ? Actualy, I compare route path to prevent function :

const path = $page.path;

const pageUnsubscribe = page.subscribe((p) => {
    if (p.path !== path) {
      return;
    }
    const min = new Date(p.query.date);
    const max = new Date(p.query.date);
    min.setUTCHours(0, 0, 0, 0);
    max.setUTCHours(23, 59, 59, 999);

    store.search(min, max);
});

But i'm not a big fan 😄

@Conduitry
Copy link
Member

This has been fixed in 0.27.13, thank you @pchynoweth!

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

Successfully merging a pull request may close this issue.

3 participants