svelte-router icon indicating copy to clipboard operation
svelte-router copied to clipboard

Improvement: currentRoute should be a store

Open artecoop opened this issue 4 years ago • 4 comments

Yo Jorge, I hope you're safe in these times of distress.

I suggest to let currentRoute to be a svelte store to listen for changes in layout pages for example.

Alternatively, expose a callback raised at every page change. This should be less breaking as a change.

artecoop avatar Mar 30 '20 07:03 artecoop

Hi @artecoop All good here, so far. I hope you are doing good as well.

The idea of converting currentRoute to a store has already crossed my mind.

Before taking any decision I'm going to start testing that locally and see how it works.

Best,

jorgegorka avatar Apr 02 '20 20:04 jorgegorka

Hi! Help please! :) How can I listen for route changes in sub-sub-sub-components (currentRoute not visible there) for duplicated navigation menu highlitning?

brandousov avatar Jun 16 '20 07:06 brandousov

EDIT: My bad. Seems like directly importing activeRoute only returns the root route info, not the current one the component is in.

bluwy avatar Jul 08 '20 15:07 bluwy

i think the import {activeRoute} from "svelte-router-spa/src/store"; should be exported in the main file like import {activeRoute} from "svelte-router-spa";

isaacwein avatar Feb 27 '23 04:02 isaacwein