Using Renderer2 Inside Services in Angular

Since Angular 4 was released Renderer class becomes @deprecated and replaced by Renderer2. It’s very frustrating to have Renderer2 as a name of class in world famous framework. That means when Renderer will be deleted in Angular version 5 or 6 from framework only Renderer2 will stay to exist. Without any connection with reality, producing …

Block scoping with let and const

@skip the bullshit @scroll to examples Since JavaScript was created we have only one way to declare variable – with a var statement. var huncode = ‘Someone who writes fast and damn simple code’; It vas several problems with var: If run outside function statements it declares in global namespace (developers writes couple of petabytes …

Docker Mail Server

As simple as install docker component on your server. Previously I’ve used laa/dockermail but after switched to more simple docker container with docker-compose Let’s go: https://github.com/tomav/docker-mailserver Install docker on your server; And install docker-compose after; Create new folder for your mailserver configuration mkdir -p ~/config/mail Create docker-compose.yml inside created folder touch ~/config/mail/docker-compose.yml Put configuration inside …

Fetch API Guide. Javascript Asynchronous request in 2018.

I still see many questions about AJAX, asynchronous callbacks and closures inside them on stackoverflow. @skip bulshit @example of usage But now Fetch API appears on scene! What is Fetch API It’s a high level API already implemented in all browsers (that real users, not bots, use): IE Edge, Google Chrome, Mozilla Firefox, Android Browser …

Object.assign performance on using with collections.

With ES2016 we have many things write shorter and look better. Small experiment of using Object.assign. I have tried to use it in reduce functions that’s convert collection to index object. For example to index by id with and without Object.assign: collection.reduce((items, item) => { items[item.id] = item; return items; }, {}); collection.reduce((items, item) => …

Angular 2 with lodash.

Simplest way to add lodash to your project is to install it with npm npm install lodash –save and add to typescript file import * as _ from ‘lodash’ But it means, that you get extra 69 Kb (23 Kb gzipped) in your build file. It’s to much if you use only couple of functions …

Upgrade Angular 2 from RC.4 to RC.5

Angular 2 on upgrade from RC.4 to RC.5 marked as deprecated HTTP_PROVIDERS, added @NgModule and changed structure of root component. If you get notice about any _PROVIDERS In RC.4 it was: bootstrap(AppComponent, [ disableDeprecatedForms(), provideForms(), HTTP_PROVIDERS ]); In RC.5 it looks like: @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, CommonModule, FormsModule, HttpModule ], providers: …