-
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rpc: add intrinsic support for async iterators
- Loading branch information
Showing
2 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { RpcPeer } from "../src/rpc"; | ||
|
||
const p1 = new RpcPeer('p1', 'p2', message => { | ||
console.log('message p1 p2', message); | ||
p2.handleMessage(message); | ||
}); | ||
|
||
const p2 = new RpcPeer('p2', 'p1', message => { | ||
console.log('message p2 p1', message); | ||
p1.handleMessage(message); | ||
}); | ||
|
||
async function* generator() { | ||
yield 2; | ||
yield 3; | ||
} | ||
|
||
p1.params['thing'] = generator(); | ||
|
||
async function test() { | ||
const foo = await p2.getParam('thing'); | ||
for await (const n of foo) { | ||
console.log(n); | ||
} | ||
} | ||
|
||
test(); |