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

Side by Side Diff: examples/js/share_echo_target.js

Issue 839553004: Mojo JS Bindings: Update User's Guide, examples (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
(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 });
OLDNEW
« examples/js/cube.js ('K') | « examples/js/share_echo.js ('k') | examples/js/users-guide.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698