Published in Dev Genius·Nov 12, 2022Typescript optimizes the search of arrayJust some ideas about includes operator in Typescript. Every day I stand in front of different task that should be solved properly. Goal: payment type should be unique in the service. …Typescript3 min readTypescript3 min read
Published in Dev Genius·Oct 19, 2022Typescript RxJs takeUntil, takeWhileHow to stop data emission in time? Reactive approach based on 3 “O” principles. Observable — Operator — Observer Observable — some input array, data stream, asynchronous collection… Operator — allow to manipulation of data that was emitted. Observer — consume emission data. With help of the operator, You will…Typescript3 min readTypescript3 min read
Published in Dev Genius·Sep 14, 2022Java best practice: boolean vs exceptionWhat to choose: method should return boolean or throw exception? This article based on some personal refactoring of old Java code, not pretend to be a mentor. Let’s suppose our method should return void or boolean. What is the most efficient way to return and how to make code clear…Java3 min readJava3 min read
Published in Dev Genius·Aug 8, 2022Angular dependency injection into the constructorBetter refactor than not to be refactored. Sometimes it is a question of what to prefer: create an instance of the class each time we call the method. Or to declare it once in a constructor. Some practical theory of DI. We can reduce the number of code strings and…Angular4 min readAngular4 min read
Published in Dev Genius·Jul 4, 2022Typescript generics is so pragmaticJust some practical programming moments from real life of Angular app. Generic methods it is a special kind of function to provide meaningful type constraints between members. function treatMethod<T>(args): TypeResult Special T char is the type variable, we can use type as a parameter of the method. …Typescript3 min readTypescript3 min read
Published in Dev Genius·May 12, 2022Angular pipe tricky momentsJust some practice ideas of pipe appear in front of me during development. The angular pipe was invented to provide an instance that will be run once until the state has changed. Pipes take the input and transform it into another type to make output in the template. …Angular Pipe5 min readAngular Pipe5 min read
Published in Dev Genius·Apr 16, 2022Typescript classical function vs arrow methodWhen to use different notation. Classical function and arrow method are quite similar, but syntax is different. Starting from ES2015, there is an arrow function syntax available: it has lightweight syntax and use anonymous function without explicit return. const result = (person) => { return `Good afternoon, ${person}`; } RxJs method…Typescript4 min readTypescript4 min read
Published in Dev Genius·Mar 22, 2022Typescript RxJS tap vs map keywordWhen to use operators for debugging. Front-end application provides certain operators for debug: debugger, console.log(). But tap keyword allows to do it in Observables. Working with observables we can process with emission of data in different way. Map, tap are operators which can be chained together inside a pipe, but…Rxjs3 min readRxjs3 min read
Published in Dev Genius·Mar 10, 2022Typescript: interface vs typeNot easy choice what to choose. What is the difference between type and interface? Find similarities: interface CruiseMissile { distance: number; modelName: string; } type CruiseMissile = { distance: number; modelName: string; }; Function types Functions can be typed by both the type and interface keywords: type Sum = (x: number, y…Typescript4 min readTypescript4 min read
Published in Dev Genius·Feb 15, 2022Typescript double “notnot” !! operatorDesign decision vs complexity and flexibility of code. I always like Typescript for strong typing and operators that make code compact. As everybody knows, char! notation just means the reverted logical state of the value. Java, Kotlin, Typescript used that widely: const myValue: boolean = true; if (!myValue) { console.log(myValue); } if…Typescript3 min readTypescript3 min read