Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Archive for October, 2017

Understanding Observables

Sunday, October 29th, 2017 by Servage
Advanced Javascript development - Part 4Observables are heavily used in frameworks like Angular. Observables are especially useful in cases where you have to respond to an event but don’t know in advance when that event is going to take place. Therefore, you can set up an observable and one or more observers that listen to the event. What Are Observables? Observables are one of the two main objects in the observer design pattern. In the observer pattern, observables are objects that one or multiple objects listen to for events they are interested in. The listening objects are called observers. How Observers Work For example, you can connect a button to an observable, and whenever the ...

Resolving Merge Conflicts in Git

Wednesday, October 25th, 2017 by Servage
gitSooner or later every developer working with Git encounters a merge conflict. Especially if you are working with other developers, it’s possible that the code you are working on is changed by someone else at the same time. When that happens, you have to choose whose work you want to keep and what to discard, or perhaps you want to combine them by taking a piece from both versions. Let’s see what tools are available to do this and how the “git mergetool” command works. How Merge Conflicts Happen A merge conflict happens when you edit a file that changes in the remote repository at the same time. When one developer first commits ...

Permission Management in PHP with Bouncer

Saturday, October 21st, 2017 by Servage
php7Permission management doesn’t sound like an easy task. Fortunately, a PHP package called Bouncer makes it rather simple. Bouncer not only handles permissions but also user groups, and you can assign permissions to those groups. For example. You can allow editors to create blog posts with only a few lines of code. Installing Bouncer Since Bouncer is a PHP package, to no surprise it can be installed using Composer by running “composer require silber/bouncer”. Bouncer is a Laravel package so therefore it only works with Laravel projects. As usually with Laravel packages, you have to add the new package to the providers array of config/app.php: “Silber\Bouncer\BouncerServiceProvider::class”. Also add the following to the aliases ...

How JavaScript Promises Work

Sunday, October 15th, 2017 by Servage
javascript-codeA promise is an object that represents an asynchronous action that is yet to be completed. Consider an HTTP request that loads the details of a user account. If the request is sent inside a promise, your application can continue to work on other tasks while the HTTP request is sent. When it completes, a function is called where you can handle the data that was returned. Let’s have a closer look at promises and what makes them so powerful. Creating a Promise A new promise can be created with the new keyword using the Promise class. Promises are created inside a function that performs asynchronous tasks. Therefore, you could have the following ...

Building a Front End with Ember.js

Sunday, October 8th, 2017 by Servage
emberEmber.js is yet another JavaScript framework for building the UI for web applications. While there seems to be many JavaScript frameworks out there at the moment, each of them is targeted for a specific use case, or at least is more suitable for something than the others. Usually a single framework is not always the best choice for all kinds of websites and web applications. Let’s explore Ember together and figure out how it works and what types of websites benefit from it the most. Ember.js Quick Start If you have ever worked with Angular, chances are you find getting started with Ember quite easy. The process of setting up your first Ember ...

Angular 4 Best Practices

Monday, October 2nd, 2017 by Servage
angularAngular is one of the most popular front-end frameworks. Developers sometimes prefer to use their own approach when it comes to naming conventions, whitespace usage, file structure and so on. However, if every developer chooses their own path to follow, managing a single code base in a team becomes quite challenging. To solve this, Angular has a set of rules that all developers should follow when working on an Angular project. Let’s have a look at those recommendations set by the team behind Angular. File Names Let’s start with file and directory naming conventions. By following the Angular naming conventions, you can easily identify what a file does just by looking at the ...