| OLD | NEW |
| (Empty) | |
| 1 #!mojo:js_content_handler |
| 2 // Demonstrate sharing services via application ServiceProviders. |
| 3 // This application is launched by share_echo.js. It both provides |
| 4 // and requests an EchoService implementation. |
| 5 // |
| 6 define("main", [ |
| 7 "console", |
| 8 "mojo/services/public/js/application", |
| 9 "examples/echo/echo_service.mojom", |
| 10 ], function(console, application, echo) { |
| 11 |
| 12 var Application = application.Application; |
| 13 var EchoService = echo.EchoService; |
| 14 |
| 15 class EchoServiceImpl { |
| 16 echoString(s) { |
| 17 return Promise.resolve({value: "ShareEchoTarget: " + s}); |
| 18 } |
| 19 } |
| 20 |
| 21 class ShareEchoTarget extends Application { |
| 22 acceptConnection(initiatorURL, shareEchoSP) { |
| 23 // The shareEchoSP parameter is-a JS ServiceProvider that's |
| 24 // connected to the share_echo.js application. We can request the |
| 25 // share_echo.js implementation of EchoService and provide the |
| 26 // share_echo.js application with our own EchoService implementation. |
| 27 var echoService = shareEchoSP.requestService(EchoService); |
| 28 echoService.echoString("ShareEchoTarget").then(function(response) { |
| 29 console.log(response.value); |
| 30 }); |
| 31 shareEchoSP.provideService(EchoService, EchoServiceImpl); |
| 32 } |
| 33 } |
| 34 |
| 35 return ShareEchoTarget; |
| 36 }); |
| OLD | NEW |