Skip to content
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

LiveReload and pathing #2144

Closed
cfjedimaster opened this issue Sep 5, 2014 · 12 comments
Closed

LiveReload and pathing #2144

cfjedimaster opened this issue Sep 5, 2014 · 12 comments

Comments

@cfjedimaster
Copy link

Ok, I ran into what I think is a major problem with the new LiveReload stuff in 1.2.0. I'm building an app where on startup, it checks to see if you are offline, and if so, does a $location.path('/offline'). To test that this works, I made that block true. I looked at the emulator and it worked perfectly, I saw the new offline page.

I then removed the code that forced that condition true and kept working. But - my app was "stuck" in the offline mode. Then I realize what it was. LiveReload was still working - reloading - but it was reloading /offline. My UI didn't have a "Home" link - nor will it since the Offline mode is an error condition - so I was stuck reloading on that particular URL, and not the home page.

Imo, the reload should start from scratch, not the current index.

@cfjedimaster
Copy link
Author

So yeah - this is really impacting me now to the point where I almost can't use it in a real app now. Any suggestions?

@adamdbradley
Copy link
Contributor

IMO this is expected behavior. Just like if your app's code was deployed to a native app, you'd have to restart the whole thing to make it work again. Having to restart everyone's app back to the index on every change would require devs to constantly navigate to the page their working on, and taking away a lot of the benefits of live reload. For example, if they are changing css and previewing the url #/users/1, then every time they change the css they'd have to navigate back to that user. Also, a lot of it depends on how the app is created. Most people will still have to click around to get back to the state their testing, but again that's on their design, and sometimes this may be unavoidable. IMO, the benefits of live reload outweighs turning it into live restart.

@adamdbradley
Copy link
Contributor

However, this does make me think, wouldn't it be cool if you could type into the terminal restart and it would restart the entire app from the index?

@cfjedimaster
Copy link
Author

I still think going back to / makes more sense - but - I'd be happy with that. Then again, if we can have that, why not just an additional flag? (Or are you trying to avoid adding so many flags that it gets confusing?)

@adamdbradley
Copy link
Contributor

Same as before. If I change a CSS color on a page a few clicks deep, I don't want to have to navigate to that page every CSS change, it defeats the purpose and one of the coolest parts of live reload. I honestly do not see the requirement to restart an app on every save. More times than not I'd rather it stay on the page I'm working on, and for that reason I don't think it restarting the whole app should be the default, but rather use a command for the few times you do want to restart it.

How about we try this route for a while and see how it works. To test out the experimental feature, run npm install -g ionic@1.2.3-beta2

Next fire up a server and app using ionic run --livereload

Then in the same terminal as the running server, type restart and hit enter. This is actually a shortcut to execute the javascript code window.location = "/";from the index page of the running app. Additionally, you can also run from the terminal goto / to do the same thing as restart. And for fun, you can even type goto http://www.google.com and your cordova app will load google's homepage.

Please let me know what you think and what we can do to improve it. Thanks

@cfjedimaster
Copy link
Author

You make a reasonable argument. I keep thinking that maybe I'm doing my Angular apps is just - well if not wrong - maybe just awkward. I'll definitely give this a shot tomorrow. Query - you mentioned "goto" - is that documented? Are there other commands?

@cfjedimaster
Copy link
Author

Confirmed it works - and I think this will work for me. I've got live reload which is awesome, and in cases where I get 'stuck', I can use goto (honestly I see myself remembering that more than restart). Thanks.

@adamdbradley
Copy link
Contributor

No its not documented yet, or even in a release, just in beta for now. I think I can also make restart and just r be an alias for goto /, but however devs want to use it is up to them. Does goto make sense, is there a better command for this? nav ? Thanks

@cfjedimaster
Copy link
Author

Well, I like goto as it reminds me of Basic (yeah, I'm that old ;).

@adamdbradley
Copy link
Contributor

I just created ionic@1.2.3-beta3, and it includes a little list of the possible commands when you start up a server. I also created aliases for each, because, why not.

Ionic server commands, enter:
 restart or r to restart the client app from the root
 goto or g and a url to have the app navigate to the given url
 consolelogs or c to enable/disable console log output
 serverlogs or s to enable/disable server log output
 quit or q to shutdown the server and exit 

If all looks good we might be ready for 1.2.3. Thanks!

(Were you the one responsible for the heartbleed goto fail!)

@cfjedimaster
Copy link
Author

Oh nice - I like being able to enable console logs in case you forget.

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 6, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants