Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
@decorators
Ben McCormick
Windsor Circle
Twitter: @ben336
Blog: http://benmccormick.org
Classes in JavaScript
(History)
• Prototypical inheritance
• Variety of approaches
Lots of MVC Libraries
Use Classes
• Backbone
• React
• Ember
• Angular
Backbone
React
Ember
ES6 Classes
• Standard clean syntax
• Fundamentally the same thing as
older inheritance models
• Browser support coming! (...
Problems with ES6
Classes
• You lose the flexibility of previous
approach
• No properties, just methods
• Strict patterns ...
So how does this get better?
Proposed JavaScript
Decorators
Decorators
• Allow customization of classes and
functions at class creation
• Restore flexibility and
expressiveness to cl...
Class Level Decorators
Method Decorators
Decorators are
• Just functions
• Take a class or method and act on it
at creation time
• Declarative! No messy code
Decorators Allow For
• Cleaner interfaces
• Class properties
• Mixins
Cleaner Interface For
Backbone
…
https://github.com/benmccormick/backbone-decorators/
`on` decorator from
Current Status
• Proposed for inclusion in ES2016
(ES7)
• Already available in TypeScript
• Usable with Babel (experimenta...
Angular2
Aurelia
Next
• ES2016 will get a draft by ~January
• Released next June (possibly with
decorators)
More info
• https://github.com/wycats/
javascript-decorators
• https://babeljs.io/docs/usage/
experimental/
Ben McCormick
Windsor Circle
Twitter: @ben336
Blog: http://benmccormick.org
Decorators Lightning Talk for Triangle JavaScript
Decorators Lightning Talk for Triangle JavaScript
Decorators Lightning Talk for Triangle JavaScript
Decorators Lightning Talk for Triangle JavaScript
Nächste SlideShare
Wird geladen in …5
×

Decorators Lightning Talk for Triangle JavaScript

335 Aufrufe

Veröffentlicht am

A quick overview of the decorator proposal for JavaScript,

Veröffentlicht in: Software
  • Als Erste(r) kommentieren

Decorators Lightning Talk for Triangle JavaScript

  1. 1. @decorators Ben McCormick Windsor Circle Twitter: @ben336 Blog: http://benmccormick.org
  2. 2. Classes in JavaScript (History) • Prototypical inheritance • Variety of approaches
  3. 3. Lots of MVC Libraries Use Classes • Backbone • React • Ember • Angular
  4. 4. Backbone React Ember
  5. 5. ES6 Classes • Standard clean syntax • Fundamentally the same thing as older inheritance models • Browser support coming! (but use Babel for now)
  6. 6. Problems with ES6 Classes • You lose the flexibility of previous approach • No properties, just methods • Strict patterns for child classes
  7. 7. So how does this get better?
  8. 8. Proposed JavaScript Decorators
  9. 9. Decorators • Allow customization of classes and functions at class creation • Restore flexibility and expressiveness to class syntax • Similar to python decorators
  10. 10. Class Level Decorators
  11. 11. Method Decorators
  12. 12. Decorators are • Just functions • Take a class or method and act on it at creation time • Declarative! No messy code
  13. 13. Decorators Allow For • Cleaner interfaces • Class properties • Mixins
  14. 14. Cleaner Interface For Backbone
  15. 15.
  16. 16. https://github.com/benmccormick/backbone-decorators/ `on` decorator from
  17. 17. Current Status • Proposed for inclusion in ES2016 (ES7) • Already available in TypeScript • Usable with Babel (experimental flag) • Key part of Angular 2 and Aurelia • Plans for using them for Ember/React
  18. 18. Angular2 Aurelia
  19. 19. Next • ES2016 will get a draft by ~January • Released next June (possibly with decorators)
  20. 20. More info • https://github.com/wycats/ javascript-decorators • https://babeljs.io/docs/usage/ experimental/
  21. 21. Ben McCormick Windsor Circle Twitter: @ben336 Blog: http://benmccormick.org

×