Skip to content

Commit

Permalink
Update initial example with function passing
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Brain authored Mar 8, 2017
1 parent ab5b30a commit 0aba0fe
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,21 @@ Send a message to another window, and:
postRobot.on('getUser', function(event) {
return {
id: event.data.id,
name: 'Zippy the Pinhead'
name: 'Zippy the Pinhead',
logout() {
currentUser.logout();
}
};
});
```

```javascript
postRobot.send(someWindow, 'getUser', { id: 1337 }).then(function(event) {
console.log(event.source, event.origin, 'Got user:', event.data.name);
var user = event.data;

console.log(event.source, event.origin, 'Got user:', user);

user.logout();

}).catch(function(err) {
console.error(err);
Expand Down

0 comments on commit 0aba0fe

Please # to comment.