GithubHelp home page GithubHelp logo

Comments (11)

aigr avatar aigr commented on May 23, 2024 1

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.

aigr avatar aigr commented on May 23, 2024

A work-around might be to do

if (event.type === 'ROUTER_END') {

Instead of

if (event.type === RouterEventType.ProgressEnd) {

from pico-router.

alshdavid avatar alshdavid commented on May 23, 2024

Hey thanks for your issue.
I'm releasing an update now to re-expose the RouterEventType.

image

Going to try to recreate your second issue to see what's going on there

from pico-router.

alshdavid avatar alshdavid commented on May 23, 2024

Export should work as of version 4.1.5
Will need to investigate further on your other issue

from pico-router.

aigr avatar aigr commented on May 23, 2024

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.

alshdavid avatar alshdavid commented on May 23, 2024

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.

alshdavid avatar alshdavid commented on May 23, 2024

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.

aigr avatar aigr commented on May 23, 2024

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.

alshdavid avatar alshdavid commented on May 23, 2024

Thanks for taking the time to put together that sandbox! I'm working on it now.

from pico-router.

alshdavid avatar alshdavid commented on May 23, 2024

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.

alshdavid avatar alshdavid commented on May 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.