In the last 2 months I have been co-authoring a new project with Sasha Khamkov called Gisto a  cross platform snippet management tool based on GitHub infrastructure written in AngularJS and wrapped around node-webkit. It is an open source project we would love if you will check out our GitHub repository and participate in the project.

 

AngularJS provided us with allot of great tools to build this application, one them includes the $http built in service.

 

$http provides you a nice clean way to create ajax requests to get your data, of course we wanted to show loading notifications while data is loading, so the user does not think something is wrong if a request happens to be lengthy due to server load or slow internet speeds.

 

Angular provides you a nice way of intercepting all $http requests using response interceptors, however this presents two issues for our use case:

 

1. Internal usage of the $http service
Angular internally uses the $http service to load things such as partial views into your application which can cause the loading notification appear in unexpected times.

 

2. The user is aware of every request
Every request you send using the $http service is being notified to the user which means if you wish to do polling requests or just check for updates in the background the user will be aware of. This isn’t always the wanted behavior.

 

 

In order to display notifications only when needed and in an automatic and unobstructive way I have created a wrapper around $http service. This service simply passes your request to the $http service fires the loading indicators and returns it to you using promises, the service mimics $http so no code changes are needed at all except for the function being called.

 

 

Here is an example use of this service:
The service code is available here:  
In summary, we have created a wrapper around the $http object so we may call it exclusively and yet easily as angular allows us, this way we can control which requests the user is aware of and build a better experience for our users.

 

Gisto is now entering alpha phase which you can download at our project page or build from source, we would very much appreciate contributions such as feedback, feature requests and pull requests.

There is still allot of work and polish to be done and we would love your feedback.