Skip to content

Commit 9b542e8

Browse files
committed
getting rpc manifest from server
1 parent 3379222 commit 9b542e8

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

host/host-script.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ const manifest = {
7676
hello: 'async',
7777

7878
//source is a pull-stream (readable)
79-
stuff: 'source'
79+
stuff: 'source',
80+
81+
manifest: 'sync'
8082
}
8183

8284
const api = {
@@ -85,6 +87,9 @@ const api = {
8587
},
8688
stuff() {
8789
return pull.values([1, 2, 3, 4, 5])
90+
},
91+
manifest: function () {
92+
return manifest
8893
}
8994
}
9095

src/page-script.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,21 @@ const toWebExt = function sink(done) {
4747
}
4848
}
4949

50-
const manifest = {
51-
//async is a normal async function
52-
hello: 'async',
5350

54-
//source is a pull-stream (readable)
55-
stuff: 'source'
5651

57-
}
52+
const client = MRPC(function (err, manifest) {
53+
if (err) throw err
54+
55+
console.log(manifest)
56+
57+
client.hello('world').then((value) => {
58+
console.log(value)
59+
})
60+
pull(client.stuff(), pull.drain(console.log))
5861

59-
const client = MRPC(manifest, null) ()
62+
console.log('adding client to window')
63+
window.client = client
64+
})()
6065

6166
const onClose = () => {
6267
console.log('connected to muxrpc server')
@@ -68,12 +73,4 @@ pull(
6873
fromWebExt,
6974
clientStream,
7075
toWebExt()
71-
)
72-
73-
client.hello('world').then((value) => {
74-
console.log(value)
75-
})
76-
pull(client.stuff(), pull.drain(console.log))
77-
78-
console.log('adding client to window')
79-
window.client = client
76+
)

0 commit comments

Comments
 (0)