| OLD | NEW |
| 1 JavaScript Mojo Example Applications | 1 JavaScript Mojo Example Applications |
| 2 ===================== | 2 ===================== |
| 3 | 3 |
| 4 hello.js, world.js - A minimal application that connects to another. | 4 hello.js, world.js - A minimal application that connects to another. |
| 5 | 5 |
| 6 wget.js - Uses the network service to load a URL. | 6 wget.js - Uses the network service to load a URL. |
| 7 | 7 |
| 8 cube.js - A JS version of examples/sample_app. | 8 cube.js - A JS version of examples/sample_app. |
| 9 | 9 |
| 10 --- Running Mojo Applications --- | 10 --- Running Mojo Applications --- |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 creates a Shell and assigns it to |this.shell|. | 94 creates a Shell and assigns it to |this.shell|. |
| 95 | 95 |
| 96 The Shell's connectToService() method returns a "proxy" to a service provided by | 96 The Shell's connectToService() method returns a "proxy" to a service provided by |
| 97 another application. | 97 another application. |
| 98 | 98 |
| 99 The JS bindings for a Mojo interface's API are delivered as a JS module whose | 99 The JS bindings for a Mojo interface's API are delivered as a JS module whose |
| 100 name is based on the '.mojom' file's path. For example, to use the Mojo network | 100 name is based on the '.mojom' file's path. For example, to use the Mojo network |
| 101 service you need the JS module based on network_service.mojom: | 101 service you need the JS module based on network_service.mojom: |
| 102 | 102 |
| 103 define("main", [ | 103 define("main", [ |
| 104 "mojo/services/public/interfaces/network/network_service.mojom", | 104 "mojo/services/network/public/interfaces/network_service.mojom", |
| 105 "mojo/services/public/js/application", | 105 "mojo/services/public/js/application", |
| 106 ] | 106 ] |
| 107 function(netModule, appModule) { | 107 function(netModule, appModule) { |
| 108 class MyApplication extends appModule.Application { | 108 class MyApplication extends appModule.Application { |
| 109 initialize(args) { | 109 initialize(args) { |
| 110 var netService = this.shell.connectToService( | 110 var netService = this.shell.connectToService( |
| 111 "mojo:network_service", netModule.NetworkService); | 111 "mojo:network_service", netModule.NetworkService); |
| 112 // Use netService's NetworkService methods. | 112 // Use netService's NetworkService methods. |
| 113 } | 113 } |
| 114 ... | 114 ... |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 response parameter. In the EchoString case that would be something like | 190 response parameter. In the EchoString case that would be something like |
| 191 {value: "foo"}. | 191 {value: "foo"}. |
| 192 | 192 |
| 193 Similarly, the implementation of a Mojo interface functions that specify a | 193 Similarly, the implementation of a Mojo interface functions that specify a |
| 194 response, must return a Promise. The implementation of EchoString() could | 194 response, must return a Promise. The implementation of EchoString() could |
| 195 be written like this: | 195 be written like this: |
| 196 | 196 |
| 197 MyEchoStringImpl.prototype.EchoString = function(s) { | 197 MyEchoStringImpl.prototype.EchoString = function(s) { |
| 198 return Promise.resolve({value: s}); | 198 return Promise.resolve({value: s}); |
| 199 }; | 199 }; |
| OLD | NEW |