OLD | NEW |
1 #!mojo:js_content_handler | 1 #!mojo mojo:js_content_handler |
2 // Demonstrate one JS Mojo application connecting to another to emit "hello | 2 // Demonstrate one JS Mojo application connecting to another to emit "hello |
3 // world". To run this application with mojo_shell, set DIR to be the absolute | 3 // world". To run this application with mojo_shell, set DIR to be the absolute |
4 // path for this directory, then: | 4 // path for this directory, then: |
5 // mojo_shell "file://$DIR/hello.js file://$DIR/world.js" | 5 // mojo_shell "file://$DIR/hello.js file://$DIR/world.js" |
6 // Launches the Mojo hello.js application which connects to the application | 6 // Launches the Mojo hello.js application which connects to the application |
7 // URL specified as a Mojo application argument, world.js in this case. | 7 // URL specified as a Mojo application argument, world.js in this case. |
8 | 8 |
9 define("main", [ | 9 define("main", [ |
10 "console", | 10 "console", |
11 "mojo/services/public/js/application", | 11 "mojo/services/public/js/application", |
12 ], function(console, application) { | 12 ], function(console, application) { |
13 | 13 |
14 var Application = application.Application; | 14 var Application = application.Application; |
15 | 15 |
16 class Hello extends Application { | 16 class Hello extends Application { |
17 initialize(args) { | 17 initialize(args) { |
18 console.log(this.url + ": Hello"); | 18 console.log(this.url + ": Hello"); |
19 if (args && args.length == 2) // args is a nullable parameter | 19 if (args && args.length == 2) // args is a nullable parameter |
20 this.shell.connectToApplication(args[1]); | 20 this.shell.connectToApplication(args[1]); |
21 else | 21 else |
22 console.log("Error: expected hello.js <URL for world.js>"); | 22 console.log("Error: expected hello.js <URL for world.js>"); |
23 this.quit(); | 23 this.quit(); |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
27 return Hello; | 27 return Hello; |
28 }); | 28 }); |
OLD | NEW |