Posts

Showing posts with the label javascript

Gluing things together

Gluing things together One of the most important things in coding is how to hold it together. In this short article I will share some thoughts on callbacks, events, observables, promises and tasks. This is what I have experienced in my time programming and I would be glad if you could share if you don't agree with me on something. Why callbacks are bad When I started programming some years ago I started with C# and Javascript. While .NET already had the Event in Javascript callbacks were everywhere. Then the word "callback hell" was coined. In short callbacks and also Events for that matter are bad because they defere the code execution to some other place which can be hard to find especially when you are following from one callback to the next for multiple steps. Therefore it pollutes the code and can separate concern which should not be separated. Why callbacks can be good Defered execution is not always bad. To create modulation and structure callbacks an...

Creating a cordova plugin and using it with ionic

In this article I will show how you can create a cordova plugin and use it in an ionic project. Prerequisites Before you can start you need to install the following tools. Node 6 LTS NPM 3+ Creating a cordova plugin Initialising the plugin To create the project files for the cordova plugin you can use use plugman which is a nice cli. I was using version 2.0.0. > npm install -g plugman ... > plugman --version 2.0.0 > plugman create ^     --name PingPong ^     --plugin_id cordova-plugin-pingpong ^     --plugin_version 0.0.1 > cd .\PingPong `plugman create` will create the following file/folder structure. PingPong   src                             <- Folder for native code   www       ...