I'm trying to wrap my head around Decorators & Metadata in Typescript and thought angular would be a good project to look for some kind of best practise.
In the old versions (e.g. 2.1) they are using DecoratorFactories and inside they apply metadta over the reflect-metadata
API proposal( http://ift.tt/2AERHRU)
In the new versions they started implementing their own system for the decorators(http://ift.tt/2yuQY49) and just appended the data to the constructor where it is easy accessible. Like:
@SomeDecorator(someDataObject)
class SomeClass { ..... }
console.log(SomeClass['__annotations__'])
console.log(SomeClass['__paramaters__'])
console.log(SomeClass['__prop__metadata__'])
Someone has any idea why they are doing this? Advantages? Disadvantages?
Aucun commentaire:
Enregistrer un commentaire