Skip to main content

Learning Session #4 - January's Meetups, Part 2


1. TypeScript Wrocław #1 – 01/30/2019

Speech #1: “TypeScript myths debunked” by Krzysztof Żuraw

Here Krzysiek presented us most popular myths about TypeScript that might discourage beginners from using TypeScript. (Of course I should not repeat myself by saying that you definitely should use it! 😉)

Most interesting points were:

- “TS is not needed when you have unit tests” – not true, because TS checks only typing and unit tests cover a lot more than that.
- “TS is strictly related to Angular” – no, you can use TS without Angular.
- “You cannot use TS with React” – we already know that you can! 😉
- “It’s hard to use external libraries with TS” – might be true, if library is strictly JavaScript-ish and has no related @types library.
- “It’s hard to introduce TS to existing project” – might be true, depends on scale of project and our eagerness to convert JS to TS 😉

Speech #2: “TypeScript with React” by Piotr Pietrzak

Piotr presented us his example application written in React with TypeScript.

Speech #3: “Developing VS Code Extensions” by Ola Sikora

Ola gave us short, but very rich and interesting presentation on creating your very own VS Code extension. I use this IDE along with IntelliJ and I love it for its flexibility and extensibility.

Here we go:

- What we need for creating extension is yo and generate-code packages.
- VS Code has API that we should use to interact with whatever is going on inside our IDE.
- We should use vsce package to publish our extension.
- List of sample extensions published by VS Code team.

Speech #4: “Handling transient errors with tryMax library” by Marcin Porębski

We heard couple of facts about transient errors and how to deal with them. What is a transient error? Well, I didn’t know either, but that mistake was quickly corrected 😉

Transient error is an error that occurs unpredictably and very rarely. When they appear we have difficulty to catch it in time or even identify what they are. With that the author of the speech came up with tryMax library. It enables retrying function or Promise with many configuration possibilities. The basic usage is to set up number of times for the function to retry before giving up and setting up delay between them.

Speech #5: “Map types in TypeScript” by Damian Paszkowski

Damian presented us use cases for map types in TS that he and his team uses in their project. For reference you can go into our Learning Session #2, where I wrote about advanced types. The talk was really educating, especially I fell in love in solution where I found out that you can convert your REST API into generic type in TS to reflect its structure. Writing all HTTP-related methods is then trivial even with auto-completion of endpoint paths enabled.

2. ng-Wrocław #26 – 01/31/2019

Speech #1: “RxCoffeeShop” by Chris Trześniewski

Another edition of one of my favorites meetups started with talk about RxJS. Chris showed us the power of this library using an application that was simulation of working coffee shop, hence the name. During that time he reviewed useful RxJS operators that he used. Some of them were:

- scan – it operates somewhat like reduce() for arrays in JS, it accumulates values over given accumulator function and returns current accumulation when new value is emitted.
- share – it shares original observable value between all subscribers.
- merge – it merges observables and emits values when they are emitted from either of those.
- zip – emits all observable values as an array after emit has ended.
- mapTo – map emitted value to constant value.

Another thing that I have learned is that there is testing library for RxJS which is called rxjs-marbles.

For more information about RxJS you can look up:
- Official RxJS docs.
- RxJS marbles where each operator’s functionality is displayed as interactive diagrams.
- Learn RxJSgreat site full of examples.

Speech #2: “Angular i18n – Current state and the future” by Piotr Lewandowski

Piotr talked about his experience in implementing internationalization in Angular apps. Generally there are to approach nowadays: using official Angular implementation and ngx-translate library. Both of them have their pros and cons and are used as often.

Piotr is using official Angular approach and these are the things he shared:

- You can use “i18n” attribute on HTML element to enable translation.
- To “i18n” attribute we can pass some metadata for element under translation like: meaning, description, custom ID, etc.
- Translations are stored in XLIFF file (special XML format).
- Every string under translation generates hash based on its value by default. We can change that by providing ID in “i18n” attribute.
- It may be a good idea to do above, because generated hashes include whitespaces, which can lead to bugs.
- Shortened process of implementing: adding “i18n” to elements, generating XLIFF via CLI, copying and translating XLIFFs to languages of choice.
- Translations are created during each application build and cannot be changed in runtime. It means that we need “n” builds of one application for “n” languages we want to support. This is biggest drawback of this approach IMO.
- Other problems of this approach: there is still a lot of bugs and there is no official release, after build the translations are generated inside of HTML, translations apply only in HTML, it is impossible to create them in other places (e.g. services).
- Official release depends on release of Angular Ivy compiler.

That is all for late January's meetup coverage. I suppose there will be more articles like this if I attend meetings as much interesting like those!

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...