Mel’s thoughts on SignalR, AngularJS and TypeScript

Mel Mason

I spent most of the DevCamp week working on the client applications: the presentation itself (minus the annotations and the graphs), the secondary screen and the audience view. So the new technologies I spent most of my time on were AngularJS and TypeScript, with a little time spent on SignalR.

Angular, SignalR and TypeScript logos

SignalR

I didn’t spend much time delving into SignalR, mostly because I didn’t need to. The code to set up a connection between clients and server is very concise and easy to understand. Tom was doing most the work on this, so it’s possible there was more complex stuff I missed, but on the bits I worked on, the main problem was figuring out how to do it properly in Angular. Without the Angular, it only took a few straightforward lines and it just worked.

We did get some intermittent problems with dropped connections – we were focusing on getting a prototype together rather than putting in a lot of error handling. It would be interesting to see how easy it is to get proper error handling client side and server side, considering the simplicity without it.

I’ve recently recommended it for a different project and I am happy to be using it again.

AngularJS

AngularJS, however, I’m still undecided on. It certainly seems very robust and full-featured – I was impressed by that. I also liked the modularisation, and how easy the data binding was. My problem with it was the learning curve.

I had previously used KnockoutJS quite heavily (a lighter-weight MVVM library which also offers data binding), and that was something I could just layer over my usual coding style and only use when I had to. To use Angular properly, I needed to completely change how I structured my code, which slowed me down considerably at the beginning. I also wasn’t sure how best to integrate it with existing non-Angular code. (Unlike Typescript, where half of us were using it and half not, and it all just fitted together).

It’s hard for me to judge how good it is until I’ve spent some more time using it, but it worked very well once I knew what I was meant to be doing. It’s probably a better library than Knockout, but certainly one that you have to invest a lot more time into at the beginning.

TypeScript

TypeScript was my favourite of the new technologies I tried out. It was exceptionally simple to start using – I installed the software, downloaded some type definitions for the libraries I was using, and then it just worked.

Annotating with types takes some getting used to, but is definitely worth it – using typescript, most of my typos or errors get caught at compile time with useful error messages. Using plain JavaScript, I might not spot them until runtime, and then have to debug why it isn’t working as expected. It saved a lot of time.

The only irritation was having to recompile the TypeScript after making changes instead of just refreshing the browser, although the TypeScript editor in Visual Studio does support compilation on save. Having modules and classes was also very nice – I suspect it would have been even more useful if I wasn’t using Angular, which implements its own modularisation.

I’ll definitely be using it in future projects.