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
Calling listen() with an optional URL to be used on its internal run() call #25
Comments
Naturally the logic to identify if I am behind Cordova or not is on my side. (I've done this) I would just like to know if it would be a problem to allow an optional argument to |
If am thinking correctly, updating the line 44 and 74 with an optional In the normal scenario, when calling $.listen = function (u) { // line 44
// ...
return $.run(u); // line 74
} Only two additional bytes to navaid 😁 😄 😅 If you approve, I can make a PR. |
Hey hey :) Would passing in Also, that'd be the wrong run – you'd have to pass |
What a fast reply! I corrected the last comment to the line 74 :)
Yes. |
It is enough because the future (non-external) URL's to be called will continue to be managed by navaid normally. And the external URL's will be opened outside the app, on the smartphone's default browser. |
Cool :) Go ahead and start a PR if you'd like. I can take care of the docs & tests if you prefer. |
Ok! |
As I've done in previous apps, I always set the app's internal links with an initial '/' so they will be not treated as relative URLs, no matter the route the user is navigating on. Everything works perfectly on smartphones this way (when packaged by Cordova). When publishing to smartphones, the URL of images are automatically prefixed with a variable to use the original path from the filesystem, on my personalized build phase, so we have zero issues with images as well. |
Yup, same. It's how most developers think of URLs so might as well write it that way too. If you know your base is some fixed Simple to reason about and implement |
I would like to update the docs and tests as well! |
Although all existing tests passed after the modification, testing the the I implemented tests with it on my browser-sync/livereload alternative project Liven. But do you think it is relevant to the project that I implement the tests with puppeteer? It seems to me like using a sledgehammer to crack a nut. 😅 |
No, I really don't want to be testing the browser. You can test it by faking the method: let expected;
let ctx = navaid();
ctx.run = function (uri) {
t.is(uri, expected;, '~> run() received expected value');
}
ctx.listen(expected = undefined);
ctx.listen(expected = '/foo'); |
Ok! 👍 |
My attempt was similar, but But I wouldn't want to disturb you if this is taking your time. I'm thinking of a solution. |
I'm happy to do it, I just don't want both of us doing the same work haha |
Ok, I will leave the tests for you. I really apologize 😅 |
Lol don't sweat it bud, thank you |
* Optional URL to the `listen()` call Solves #25 * chore: add `listen()` tests * chore: update docs Co-authored-by: Luke Edwards <luke.edwards05@gmail.com>
Now available as |
Hello, Luke!
I am implementing navaid as a long-lived router on an app that will be used both on web and smartphones (through Cordova).
Is there an option on navaid to avoid the automatic call of
run()
when callinglisten()
or a way to provide a specific URL to this first call, like/
instead of the current URL?This helps my app to run fine on smartphones as well, because otherwise the
run()
call will fail with the initial URL provided by Cordova, that is something likefile:///home/user/app/directory/index.html
.I used Page.js to to this before, and on the smartphones I used its
dispatch: false
option to avoid this firs "run". But Navaid is so incredibly smaller that I prefer it over Page.js.Thanks again!
The text was updated successfully, but these errors were encountered: