h-ubu - CDI in JavaScript

721 views
583 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
721
On SlideShare
0
From Embeds
0
Number of Embeds
112
Actions
Shares
0
Downloads
3
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

h-ubu - CDI in JavaScript

  1. 1. DynamisTechnologies h-ubu CDI in JavaScript Clement Escoffier
  2. 2. How do we do that in Java ?
  3. 3. Components
  4. 4. Interfaces
  5. 5. Dependency Injection
  6. 6. What do we have in JavaScript ?
  7. 7. Module Patterns + -Fix visibility A bit complex No interfaces
  8. 8. Module loaders + -Avoid <script> Hard-coded Transitive dependencies Reuse
  9. 9. MVC / MVVM + - Code Pushingorganization the limitsUI Bindings
  10. 10. Well, so what’s h-ubu ?
  11. 11. Service-based Injection Framework
  12. 12. hub
  13. 13. components
  14. 14. var component = { configure : function(hub, conf) { }, getComponentName : function() { }, start : function() { }, stop : function() {}};hub .registerComponent(component) .start()
  15. 15. contracts
  16. 16. var myService= { doSomething : function() {}}
  17. 17. services
  18. 18. services Service Registry 2 – Lookup, 1 - PublicationService Listener 3 - Binding
  19. 19. Substitutability Loose-coupling Why services ? TestableDynamic
  20. 20. var provider = { configure : function(hub, conf) { hub.provideService({ component: this, contract: myService }); }, getComponentName : function() { }, start : function() { }, stop : function() {}, doSomething : function() { … }}
  21. 21. var consumer = { configure : function(hub, conf) { hub.requireService({ component: this, contract: myService, field: "svc" }); }, getComponentName : function() { }, start : function() {}, stop : function() {}, work : function() { this.svc.doSomething(); }}
  22. 22. var consumer = { configure : function(hub, conf) { hub.requireService({ component: this, contract: myService, field: "svc" }); }, getComponentName : function() { }, start : function() {}, stop : function() {}, work : function() { } this.svc.doSomething(); Proxy}
  23. 23. events
  24. 24. var publisher = { configure : function(hub, conf) {} getComponentName : function() { }, start : function() {}, stop : function() {}, work : function() { this.hub.publish(this, "my/topic", event); }}
  25. 25. var receiver = { configure : function(hub, conf) { hub.subscribe(this, "my/(.)*?", this.receive); }, getComponentName : function() { }, start : function() {}, stop : function() {}, receive: function(event) { }}
  26. 26. require.js/node.js Composition Modularize your JavaScript StandaloneConfigurability
  27. 27. h bu Stop hacking, Start composinghttp://nanoko-project.github.com/h-ubu/snapshot/

×