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.
sudo npm install -g cocoonjs
Then, you can create a new project, as always:
$ cocoonjs create MyProject com.ludei.test LudeiTest
$ cd MyProject
$ cocoonjs platform add android
$ cocoonjs serve
You’ll read a message like this one:
[CocoonJS] Executing command 'serve'
[CocoonJS] A 'cordova prepare' is needed before executing 'cordova serve'.
[CocoonJS] Command 'cordova prepare' executed correctly.
[CocoonJS] Static file server running on port 8070 (i.e. http://192.168.0.43:8070)
[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!