Skip to main content

Learning Session #8


This time I’ve got an interesting batch of conference talks, as I listened to talks from recent conferences, like ngConf and Uphill Conf. ngConf is the probably the biggest Angular conference in the world and I would love to attend it someday! (Watching live feeds from people on Twitter made me envy them so much…)

1. Conference talks

>> “Wrapping it up with decorators” by Nicole Oliver

Decorators are probably the most underused TypeScript feature when developing Angular apps (at least for me). They let you modify existing functionalities of class and its members.

First time I’ve heard of an idea of decorators was in Java (there called “annotations”). They are part AOP (Aspect Oriented Programming) and allow you to extract repeatable functionality and reuse it. It takes shape of a function of a certain type (different type for class, field or method to decorate).

Nicole shows us not only how to create and use basic decorator in TS. She also shows us how they work internally and how to use basic concepts of meta-programming in JS for our advantage (with PropertyDescriptor).

>> “Can you imagine a future without zones?” by Maxim Koretskyi

We happened to talk about zones already and how crucial they are, especially in Angular. Maxim shows us an example Angular app and how we can maneuver with its settings to enable, disable and optimize zone usage and what are the consequences of those actions. We also get to know how Angular itself takes advantage of Zone.js library.

>> “CDK Is The Coolest Thing You Are Not Using” by Jeremy Elbourn

Here we hear the news related to Angular Material and CDK changes (recent or near-future ones). Angular Material is a library of the most often used UI components (like navbars, cards, lists, drag and drop, etc.). On the other hand, CDK gives us, developers, tools for creating components ourselves.

Jeremy shows us the newest components in the Material family and how he and his team are working towards further evolution of the projects.

>> “20 RxJS operators in 20 minutes by Mike Brocchi & John Niedzwiecki

Mike and John present us with 20 common and uncommon RxJS operators. They do their speech brilliantly with both humor and expertise (I don’t mind dad jokes at all, even while not being one myself ๐Ÿ˜‰). I wrote some of those operators down in my own RxJS dictionary.

>> “RxJS Recipes” by Dominic Elm and Kwinten Pisman

This is a wonderful talk about common RxJS patterns. With the sample app, Dominic and Kwinten present us how to solve problems with “divide and conquer” approach and making use of patterns and recipes.

Watching this talk, in particular, made me very excited, as they opened my eyes on how useful can RxJS actually be. Thanks to great talks like that, reactive programming is starting to feel much more natural for me when developing web apps. I wish there was a book/course on advanced RxJS patterns somewhere out there.

Does anyone know some?

2. JavaScript misc.

>> RxJS: Subscription and add()

This is one a very useful tip I found a while ago and it is worth sharing, as I see many people are unaware of this. You can add multiple subscriptions to one Subscription instance and then .unsubscribe() it whenever necessary to unsubscribe from all of them at once.

I mention it because I see a lot of people solving this problem by creating an array of Subscription instances and looping over them and unsubscribing. I also see some people sharing some npm libraries which solve this non-existing problem.

>> “Debugging RxJS” and rxjs-spy by Nicholas Jamieson

I found out a nice way of getting valuable information on your Observable instances currently running in your app. For that, use rxjs-spy npm package. With one command in the browser’s console, you can extract the state of your observables, how many subscribers it has, what is the value inside, etc.

I used and it was incredibly helpful, as I found a couple of subscription leaks, totally unaware of them before.

>> Typed reactive forms in Angular?

[GitHub issue] [@ng-stack/forms] [ngx-strongly-typed-forms]

One thing I found awkward about reactive forms in Angular, that they are not as strongly typed as I wish them to be.

There is already a GitHub issue for that (linked above). For now, we can create our own type aliases that suit our needs or use external solutions, like those above.

I saw that there is an already rough discussion on that topic going on. People want (even demand) new functionalities over and over. There is probably a lot going on in the Angular team already, so please, be patient and understanding. Those folks are doing a really good job.

>> Promise: then() + error callback vs catch()

Interesting thread on using one of many Promises’ features. I was wondering what’s the difference between using error callback in then() or just using catch().

TL;DR: Using error callback might miss error that would occur in handler inside then(). So… If we want to handle errors properly we should always use catch(), right? Yup, JS is weird.

>> Does unresolved Promise cause memory leak?

Here is Stack Overflow thread on that topic exactly. I was wondering what are the consequences of not resolving a Promise.

One thing is sure, if you create a Promise that never resolves/rejects, you create forever-pending Promise instance. I think that one of the comments says it all:

@cdhowie: “There's some truth in these comments and some that's misleading, so let me clarify: A promise with handlers attached might be eligible for garbage collection. A promise is kept alive (not GC-eligible) if any of the following are true: (1) there is a reference to the promise object, (2) there is a reference to the "deferred" state of the promise (the object/functions you use to resolve/reject it). Outside of this, the promise is eligible for GC. (If nobody has the promise and nobody can change its state, what is its purpose anymore, anyway?”

3. Other

>> "Awesome" GitHub repository

This repository is one of the best and the biggest learning resources you can find on the Internet. It consists of many references to learning articles, tutorials, courses, videos, etc. A great starting point if you want to level up as a developer. I personally found many resources on the basics of functional programming and Elm there.

Comments

Popular posts from this blog

Learning Session #2 (12/31 – 01/13)

1. Git >> Free and (almost) unlimited private repositories on GitHub Last week everyone on Twitter was talking about this so I can't just leave that be, right? ๐Ÿ˜‰ What I’m referring to is GitHub announcing free and unlimited private repositories for all users. That’s a great news and I was wondering why this option was not enabled from day one I started using GitHub. I mentioned that this option is “almost” unlimited because free private repository can manage up to three collaborators only. Big projects won’t be able to use those, but at least individual users can now freely hide code they consider shameful ๐Ÿ˜‰ 2. React >> React Crash Course by Mosh Hamedani During last two weeks I’ve completed this YouTube crash course by Mosh Hamedani. It is derived from his full course on React and contains first couple of lessons. It think it was a great introduction to the library itself (React is a considered a library, not a framework, isn’t it? ๐Ÿ˜Š). Tutorial ends ...

How I started with Functional Programming

There was a moment during past Learning Sessions when I declared, that I’ll share with you how and why I decided to dive into Functional Programming. And that day is today! I’ll guide you along the path I took to understand basic concepts of FP. My first meaningful encounter with FP was during local Wrocล‚aw TypeScript meetup . There I got to hear Jรณzef Flakus telling us about core concepts of the FP. We then got to the concept of FRP and how it is used in MarbleJS, the framework for creating server-side apps. In fact, Jรณzef is the creator of this framework. It was really cool to hear his point of view. Those concepts were entirely new to me, because (as it turned out) I had 100% imperative programming mindset. The second talk that day was authored by Tomasz Ducin. He showed us how we can implement functional composition in TypeScript. It was a brilliant live coding session but… I had no idea what he was talking about ๐Ÿ˜‰ I was examining code created by Tomasz for the entire ...

Programmer's Bookshelf - "The Pragmatic Programmer"

“People should see your name on a piece of code and expect it to be solid, well written, tested, and documented.” ~ David Thomas, Andrew Hunt Today I proudly finished “The Pragmatic Programmer” by David Thomas and Andrew Hunt ๐Ÿ˜Š  I recommend it to anyone looking for solid tips for every aspect of developer’s work: from technical to project management. Also, it may just ensure you in the correctness of your workflow ๐Ÿ˜Š What I have learned from the book:   - „Provide Options, Don’t Make Excuses” – take responsibility for your errors and provide solutions. - “Don’t Live with Broken Windows” – prevent damage to your projects by not ignoring anything potentially harmful and fixing it. - “Invest Regularly in Your Knowledge Portfolio” – embrace any opportunity to learn! - “Involve your users in the trade-off” – remember that you’re writing software for other people. - Users not only decide what they want but also when they want it and how good it should be...