Comments (11)
But other things have changed as well.
If I have something like
nav.path('/browse/:cname', (req, res) => {
const sub = nav.events.subscribe(event => {
// if (event.type === RouterEventType.ProgressEnd) {
if (event.type === 'ROUTER_END') {
res.mount(Collection, { req, nav })
}
})
res.onLeave(() => sub.unsubscribe())
})
Then previously a call to nav.navigate('/browse/foo')
, while "being" on '/browse/bar'
worked out. Now I need to click links twice for it to flip.
from pico-router.
A work-around might be to do
if (event.type === 'ROUTER_END') {
Instead of
if (event.type === RouterEventType.ProgressEnd) {
from pico-router.
Hey thanks for your issue.
I'm releasing an update now to re-expose the RouterEventType
.
Going to try to recreate your second issue to see what's going on there
from pico-router.
Export should work as of version 4.1.5
Will need to investigate further on your other issue
from pico-router.
Hmm. Perhaps I'm doing something wrong, but it doesn't seem to work for me
$ jq '.dependencies.crayon.version' package-lock.json
"4.1.5"
And then
$ npm run build
...
[!] Error: 'RouterEventType' is not exported by node_modules/crayon/dist/index.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
svelte/main.js (3:17)
3: import crayon, { RouterEventType } from 'crayon'
^
Error: 'RouterEventType' is not exported by node_modules/crayon/dist/index.js
from pico-router.
It seems good here:
JavaScript:
https://stackblitz.com/edit/typescript-akyrxk
TypeScript:
https://stackblitz.com/edit/js-7yh9tp
Did you try uninstalling/installing it again?
npm uninstall --save crayon
npm install -save crayon
from pico-router.
I have added the following test to the latest current version:
it('Should ', async (done) => {
const window = new MockWindow() as any
const app = create('test-router', window)
let hasClicked = false
app.path('/browse/:cname', (req, res) => {
const sub = app.events.subscribe(async event => {
if (event.type !== RouterEventType.ProgressEnd) {
return
}
if (hasClicked == true) {
done()
return
}
hasClicked = true
await app.navigate('/browse/b')
})
res.onLeave(() => sub.unsubscribe())
})
await app.load()
await app.navigate('/browse/a')
})
Does that cover your use case? If not, could you set up a code sandbox illustrating your case?
from pico-router.
Still doesn't work for me locally, but that must surely be some kind of mistake on my part. It seems to work out well elsewhere. 😄
W.r.t to my second problems, where links have to pressed twice to change, I've made a minimalistic example of it at https://codesandbox.io/s/sweet-taussig-2q3wb.
You go "Home", press "foo", then keep pressing the links for "next".
(I've somehow messed up the transitions, but that's another story)
from pico-router.
Thanks for taking the time to put together that sandbox! I'm working on it now.
from pico-router.
Just a quick update on this.
app.events.subscribe(event => {
if (event.type !== "ROUTER_END") {
return
}
console.log(window.location.pathname)
console.log(req.params.name)
});
req.params.name
lags behind window.location.pathname
So It seems like I'm not updating the request at the right time.
Looks like the RouterEventType
value is available in TypeScript, but not in JavaScript. Looking into that too.
from pico-router.
RouterEventType
is now exported on the default crayon export
You can check out this sandbox
https://codesandbox.io/s/svelte-khjjw?fontsize=14&hidenavigation=1&theme=dark
I'll be enhancing the documentation soon, but for now to access RouterEventType
do the following:
import crayon from 'crayon'
console.log(crayon.RouterEventType.ProgressStart)
Let me know if you have any issues, otherwise I'll close this issue for now
from pico-router.
Related Issues (20)
- [all] Ensure components are unmounted when a router is destroyed HOT 1
- TypeError: app.history.currentEvent is undefined HOT 3
- Crayon-Svelte Component Intro HOT 3
- Return to Page Location HOT 2
- Svelte nested routing example HOT 6
- Support for protected routes HOT 2
- svelte-basic example doesn't work - error in commonjs - Cannot read property 'type' of null HOT 4
- Route parameter converted to lowercase HOT 4
- Route called even when middleware use redirection HOT 2
- More detailed Svelte example HOT 7
- Not a function: res.redirect , res.mount HOT 3
- crayon.group() needs to match empty, '' and '/' as the base route
- push/pop middleware for Preact
- wrong svelte logo HOT 1
- Is there an example or setup for using a route guard? HOT 5
- TypeError: res.redirect is not a function HOT 3
- `res` instead of `req` with svelte example HOT 1
- crayon-animate has gone from npm!!! HOT 4
- Is this project dead? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pico-router.