Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1203)

Side by Side Diff: examples/js/users-guide.md

Issue 1404443004: Move //mojo/services/network/public/interfaces to //mojo/services/network/interfaces. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: add some missing dependencies Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « examples/http_handler/http_handler.cc ('k') | examples/js/wget.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Running Mojo Applications 1 # Running Mojo Applications
2 2
3 A Mojo application written in JavaScript is launched with mojo_shell like this: 3 A Mojo application written in JavaScript is launched with mojo_shell like this:
4 4
5 ``` 5 ```
6 mojo_shell <js-application-url> 6 mojo_shell <js-application-url>
7 ``` 7 ```
8 8
9 Where js-application-url is a URL understood by the shell. For example 9 Where js-application-url is a URL understood by the shell. For example
10 a file or an http URL that names a JS source file. The JS file itself 10 a file or an http URL that names a JS source file. The JS file itself
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 service's Mojo interface. The bindings are generated by the build system and end 108 service's Mojo interface. The bindings are generated by the build system and end
109 up in files whose name is the same as the '.mojom' file with a '.js' 109 up in files whose name is the same as the '.mojom' file with a '.js'
110 suffix. It's often helpful to look at the generated '.mojom.js' files. 110 suffix. It's often helpful to look at the generated '.mojom.js' files.
111 111
112 The JS bindings for a Mojo interface's API are delivered as a JS module whose 112 The JS bindings for a Mojo interface's API are delivered as a JS module whose
113 name is based on the '.mojom' file's path. For example, to use the Mojo network 113 name is based on the '.mojom' file's path. For example, to use the Mojo network
114 service you need the JS module based on network_service.mojom: 114 service you need the JS module based on network_service.mojom:
115 115
116 ```javascript 116 ```javascript
117 define("main", [ 117 define("main", [
118 "mojo/services/network/public/interfaces/network_service.mojom", 118 "mojo/services/network/interfaces/network_service.mojom",
119 "mojo/services/public/js/application", 119 "mojo/services/public/js/application",
120 ] 120 ]
121 function(net, application) { 121 function(net, application) {
122 class MyApplication extends application.Application { 122 class MyApplication extends application.Application {
123 initialize(args) { 123 initialize(args) {
124 var netService = this.shell.connectToService( 124 var netService = this.shell.connectToService(
125 "mojo:network_service", net.NetworkService); 125 "mojo:network_service", net.NetworkService);
126 // Use netService's NetworkService methods. 126 // Use netService's NetworkService methods.
127 } 127 }
128 ... 128 ...
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 325
326 The JS Shell class simplifies connecting to applications and services. It's a 326 The JS Shell class simplifies connecting to applications and services. It's a
327 wrapper for the Application's appShell argument. The Application constructor 327 wrapper for the Application's appShell argument. The Application constructor
328 creates a Shell and assigns it to `this.shell`. 328 creates a Shell and assigns it to `this.shell`.
329 329
330 The Shell's connectToService() method returns a "proxy" to a service provided by 330 The Shell's connectToService() method returns a "proxy" to a service provided by
331 another application. 331 another application.
332 332
333 ```javascript 333 ```javascript
334 define("main", [ 334 define("main", [
335 "mojo/services/network/public/interfaces/network_service.mojom", 335 "mojo/services/network/interfaces/network_service.mojom",
336 "mojo/services/public/js/application", 336 "mojo/services/public/js/application",
337 ] 337 ]
338 function(net, application) { 338 function(net, application) {
339 class MyApplication extends application.Application { 339 class MyApplication extends application.Application {
340 initialize(args) { 340 initialize(args) {
341 var netService = this.shell.connectToService( 341 var netService = this.shell.connectToService(
342 "mojo:network_service", net.NetworkService); 342 "mojo:network_service", net.NetworkService);
343 // Use netService's NetworkService methods. 343 // Use netService's NetworkService methods.
344 } 344 }
345 ... 345 ...
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 493
494 The echo_share.js and echo_share_target.js applications demonstrate this. 494 The echo_share.js and echo_share_target.js applications demonstrate this.
495 495
496 ## Final note 496 ## Final note
497 497
498 An initiator's serviceProvider object can be retained and used to 498 An initiator's serviceProvider object can be retained and used to
499 request or provide services at any time, not just from within 499 request or provide services at any time, not just from within
500 application's acceptConnection() method. 500 application's acceptConnection() method.
501 501
502 502
OLDNEW
« no previous file with comments | « examples/http_handler/http_handler.cc ('k') | examples/js/wget.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698