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

Unified Diff: examples/js/README.md

Issue 803173009: Mojo JS Bindings: Eliminate foo$ Stub and Proxy class members (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | examples/js/wget.js » ('j') | mojo/public/js/bindings.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/js/README.md
diff --git a/examples/js/README.md b/examples/js/README.md
index 153c8723045c70d439b4f6281579d919f3d8fa2f..9fafa91e41462e2d00b3cd4fc9283eb54cf62d6c 100644
--- a/examples/js/README.md
+++ b/examples/js/README.md
@@ -35,8 +35,8 @@ This is the overall structure of a JS Mojo application:
define("main", ["mojo/services/public/js/application",
<list of other modules that this application depends on>
],
- function(appModule, <one parameter per dependent module>) {
- class MyApplication extends appModule.Application {
+ function(application, <one parameter per dependent module>) {
+ class MyApplication extends application.Application {
constructor(appShell, url) {
super(appShell, url); // Initializes this.shell, this.url.
// MyApplication initializations here.
@@ -104,11 +104,11 @@ service you need the JS module based on network_service.mojom:
"mojo/services/network/public/interfaces/network_service.mojom",
"mojo/services/public/js/application",
]
- function(netModule, appModule) {
- class MyApplication extends appModule.Application {
+ function(net, application) {
+ class MyApplication extends application.Application {
initialize(args) {
var netService = this.shell.connectToService(
- "mojo:network_service", netModule.NetworkService);
+ "mojo:network_service", net.NetworkService);
// Use netService's NetworkService methods.
}
...
@@ -297,19 +297,18 @@ The caller and callee use cases that follow are in terms of the following mojom
requestFoo(Foo& foo); // effectively: provideFoo(Bar bar)
}
--- In General
+-- Stubs and Proxies
-From a user's point of view, the bindings are in terms of the (remote)
-proxy class and the (local) stub class's implementation delegate
-(internally, that's the stub class's delegate$ property). The
-bindings will add/use a local$ property on proxy objects which points
-to the stub class's implementation delegate. They also manage remote$
-property on the implementation delegate whose value is the proxy.
+TODO: briefly introduce message pipes.
+TODO: explain what stubs and proxies are, explain what's meant by "local" and "remote".
+TODO: explain the StubBindings and ProxyBindings functions.
+TODO: support creating a proxy from a handle new MyProxy(someHandle);
+TODO: explain the Connection object and how it relates to this stuff.
-All that implies:
+From a user's point of view, the bindings are in terms of the (remote)
+proxy class and the (local) stub class. Properties are added to instances
+of these classes using functions called StubBindings and ProxyBindings.
-fooImpl.remote$.local$ == fooImpl (the stub class's delegate)
-fooProxy.local$.remote$ == fooProxy
-- Callers
@@ -319,16 +318,23 @@ Assuming that we have a proxy for interface I, iProxy.
An iProxy.provideFoo() call implies that we have an implementation of
Foo, and want a proxy for Bar (Foo's client).
- var myFooImpl;
- provideFoo(myFooImpl);
- myFooImpl.remote$; // A Bar proxy initialized by provideFoo(), undefined if Foo has no client.
+ var barProxy;
+ iProxy.provideFoo(function(remote) {
+ barProxy = remote;
+ return myFooImpl;
+ });
An iProxy.requestFoo() call implies that we have an implementation of
Bar and want a proxy for Foo (Bar's client).
- var myBarImpl; // If Foo has no client then this is just {}.
- requestFoo(myBarImpl);
- myBarImpl.remote$; // A Foo proxy initialized by requestFoo.
+ var fooProxy;
+ iProxy.requestFoo(function(remote) {
+ fooProxy = remote;
+ return myBarImpl;
+ });
+
+In the requestFoo() case, if no client were defined for Bar the function
+parameter need not return anything.
The wget.js example includes a request for the URLLoader service.
@@ -339,7 +345,7 @@ implementation of Bar (Foo's client) and want a proxy to the Foo
that has been passed to us.
void provideFoo(fooProxy) {
- fooProxy.local$ = myBarImpl; // sets myFooImpl.remote$ = fooProxy
+ ProxyBindings(fooProxy).setLocalDelegate(myMyBarImpl);
}
An implementation of requestFoo(Foo& foo) implies that we have an
@@ -347,6 +353,6 @@ implementation of Foo and want a proxy for the Bar (Foo's client)
that's been passed to us.
void requestFoo(barProxy) {
- barProxy.local$ = myFooImpl; // sets myFooImpl.remote$ = barProxy
+ ProxyBindings(barProxy).setLocallocalDelegate(myFooImpl);
}
« no previous file with comments | « no previous file | examples/js/wget.js » ('j') | mojo/public/js/bindings.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698