Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit 299b0a2

Browse files
author
Daniel Brain
committed
Docs
1 parent 62616be commit 299b0a2

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

README.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Send a message to another window, and:
1717
```javascript
1818
postRobot.on('getUser', function(event) {
1919
return {
20+
id: event.data.id,
2021
name: 'Zippy the Pinhead'
2122
};
2223
});
@@ -51,6 +52,7 @@ postRobot.on('getUser', { id: 1337 }, function(event, callback) {
5152

5253
setTimeout(function() {
5354
callback(null, {
55+
id: event.data.id,
5456
name: 'Captain Pugwash'
5557
});
5658
}, 500);
@@ -126,6 +128,7 @@ postRobot.on('getUser', async ({ source, origin, data }) => {
126128
let user = await getUser(data.id);
127129

128130
return {
131+
id: data.id,
129132
name: user.name
130133
};
131134
});
@@ -149,6 +152,7 @@ to and send messages to. This creates a secure message channel that only works b
149152
```javascript
150153
postRobot.on('getUser', { window: childWindow, domain: 'http://zombo.com' }, function(event) {
151154
return {
155+
id: event.data.id,
152156
name: 'Frodo'
153157
};
154158
});
@@ -170,19 +174,18 @@ Post robot lets you send across functions in your data payload, fairly seamlessl
170174
For example:
171175

172176
```javascript
173-
// Window 1:
174-
175177
postRobot.on('getUser', function(event) {
176178
return {
177-
name: 'Nogbad the Bad',
179+
id: event.data.id,
180+
name: 'Nogbad the Bad',
181+
178182
logout: function() {
179183
currentUser.logout();
180184
}
181185
};
182186
});
183187

184-
// Window 2:
185-
188+
```javascript
186189
postRobot.send(myWindow, { id: 1337 }, 'getUser').then(function(event) {
187190
var user = event.data;
188191

0 commit comments

Comments
 (0)