Loading data at startup in a Ionic app

I’m working on a Ionic app that loads data at startup and also checks to see if this data is available everytime a view loads.

So to do this I’ve created a Service that loads the data, this I can call within the run function in the main JavaScript file, where I set up the routes using ui-router.

These run functions, and there can be more than one, are called when the application first runs.

.run(function(StartupService){
    StartupService.loadData();
})

In the above example I can call a function from my StartupService. The loadData() function then can load the data into localStorage so it is accessible when offline.

This was all fine, but I also wanted to check when a view loads to see if the data is accessible from local storage. Looking through the great documentation on the Ionic website there are a set of events that the ion-view has including:

  • $ionicView.loaded
  • $ionicView.enter
  • $ionicView.leave
  • $ionicView.beforeEnter
  • $ionicView.beforeLeave
  • $ionicView.afterEnter
  • $ionicView.afterLeave
  • $ionicView.unloaded

All these lifecycle events can be listened for, using the $scope.$on event handler.

So I used the $ionicView.enter event to make a call to see if the data was available in local storage.

This may not be the ideal approach, but it does work. The one thing I did get from this was the use of the event lifecycle for views and how it can help to tie into them.

A great article on these views and the lifecycle events is Navigating the Changes from the Ionic blog.

Distributed teams

Today I’ve been working from home, thankfully the client I’m working for sometimes allows me to do this if I need to. I was thinking about remote working and how it has changed and grown so much over the last few years.

Back when I started in the web industry many years ago, one of the first places I worked at had a small team for this web stuff, and eventually they went off on their own and I was asked if, as the junior developer, I’d like to go with them on their new adventure.

So for the first few weeks we as a team of three was a distributed team, each working from their homes. Back then all I had was a dial up, a old computer with a CRT (remember them), Dreamweaver and FTP. Whenever I need to talk to another member of the team, we’d email a time to talk. Then I’d unplug the telephone line from the computer, plug the phone in and speak to my team mate. This was about 14 years ago so mobiles were just coming out.

Now sitting here I have a laptop, wifi, Dropbox and Slack/Glitter all keeping me in touch with not only the other members of my team, but developers all over the world. I can sync all my changes through Dropbox, so when I’m back in the office I can check in to the build server, all the work I’ve done here.  Through things like Slack/Glitter I can speak to other developers on any project I have in Github.

In America it looks like the distributed team approach has really taken off. In the UK businesses are not as open to the idea, mainly established businesses are not keen on this model. New startups are looking at this approach, but being in a smaller country compared to the US, I think UK firms are still new to the distributed model, which is a shame because now it is some much easier to work this way. I’m sure top developers are put off by a role when they see how long the commute is, if more companies were open to this way of working then they might find the best developers for their team/project.

Why hybrid apps is a growing trend for 2015

There is an interesting article on the Universal Mind blog about the upcoming trends in 2015. One of these trends is Hybrid Apps.

In the article the author, Peter Traeg, talks about how the recent updates in the webviews for both Android and iOS have made great steps forward in performance. This with the latest phones be more powerful, mean that hybrid apps are no longer slow, badly performing apps.

This, with the new set of hybrid frameworks, like Ionic, Famo.us, Polymer and TouchstoneJS. Hybrid app development is really growing and becoming a viable option for app development.

As a web developer I am a big fan of hybrid development, being able to use the web skills I’ve been using over the last 16 years I can create fully featured, cross platform apps.

New Site

After reading the great book Soft Skills from John Sonmez I decided to setup a new site for CGCSoftware.

The previous site was a simple HTML/Bootstrap site I created quickly over a weekend and it hasn’t been updated ever since.

So after reading through John’s book and his thoughts on how the blog is one of, if not the most important part of a developers branding/self promotion. I decided that it was time to upgrade both the CGCSoftware website to a blog.

I have used other blogging tools like Blogger and Medium, but (as John says) they don’t let you have totally brand or control your blog, so I’ve gone for a WordPress installation.

There is still some work I need to do to this site as part of my re-branding. I need to change the colour scheme of this site and continue writing a regular blog.