DEV Community

Discussion on: Why Choose NgRx?

Collapse
 
korbraan profile image
Cédric Rémond

The NgRx team is doing a great job for sure and they recently reduced the minimal amount of code to write, but to me the use of decorators is a huge plus, especially in the context of Angular that makes heavy use of decorators. It just feels like home to use NgXs decorators.

Thread Thread
 
layzee profile image
Lars Gyrup Brink Nielsen

There's a big difference. Angular's decorators are compiler instructions and are not present at runtime.

Thread Thread
 
korbraan profile image
Cédric Rémond

Oh, never thought of that.

But once compiled the decorators are just functions no? What is the drawback of decorators, even if executed at runtime to you? Only the fact they aren't standard yet?

Thread Thread
 
layzee profile image
Lars Gyrup Brink Nielsen • Edited

Non-Angular decorators are function wrappers, yes. But the structure and semantics of decorators, even the syntax can still change. Heck, decorators might never make it into the language (that language is ECMAScript, not TypeScript).

If syntax and semantics change, don't bet on TypeScript saving our behinds. When we use decorators in TypeScript, we enable the option "experimentalDecorators", meaning: "You're on your own, pal. Good luck!". It's called experimental for a reason (that reason is Angular by the way, there used to be this language called AtScript).