At Ludei coding never stops, and today, we’d like to introduce to you the new feature we’ve added to our CocoonJS Command Line Interface: live reload.
For those who don’t know what live reload is, this feature reloads automatically the code of your app inside the connected browsers each time you save your changes. This way you forget about saving, going to the launcher, and refreshing the content to see the changes every time.
How do I benefit from this new feature?
First of all you must update your cocoonjs-cli version. You can find more information about our CLI here.
Then, you can create a new project, as always:
$ cd MyProject
$ cocoonjs platform add android
$ cocoonjs serve
You’ll read a message like this one:
[CocoonJS] A ‘cordova prepare’ is needed before executing ‘cordova serve’.
[CocoonJS] Command ‘cordova prepare’ executed correctly.
[CocoonJS] Path: /Volumes/data/hello-world
[CocoonJS] CTRL + C to shut down
Now, open a launcher an point to that web address. In our case http://172.16.100.43:8070. You’ll find the default main page. Also, if you are working in the same machine where the command was executed, you can point to the loopback/localhost interface (127.0.0.1).
Open the contents of the www folder with your code editor, and edit them. Each time you save the code, the launcher will refresh with the new content!
The video below is a good demo.
We hope you’ll love it!