What is a reflector class in Angular2?

I am learning Angular2 and the team is actually using the "reflector class".

This isn't the first time I've come across this term and I really don't know what it refers to.

What is a "reflector class" in Angular2 ?

Why is this so useful?

+3


source to share


1 answer


@Component()
@View()

      

You probably see it attached to a class in Angular 2. The Angular team called these "annotations".

Only now ES7 proposal from Yehuda Katz can bring this metadata for all JavaScript. They will also be called Decorators, and you can already find decorators in TypeScript .



But wait! Angular has already called something "decorators". Need to rename this too. Who knew these concepts also have name conflicts.

So, I'm not sure what is called what's called these days, but if you can't wait for the dust to settle, I think the "reflectors" are related to the Reflector API for decorators , which you can read in a future article on decorators here ... They are very similar to "annotations".

+2


source







All Articles