Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<script src="https://rawgit.com/angular/bower-angular/master/angular.min.js"></script>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>bufferCount</title>
  <script src="https://npmcdn.com/@reactivex/rxjs@5.0.0-beta.3/dist/global/Rx.umd.js"></script>
</head>
<body>
</body>
</html>
 
const studentObs = Rx.Observable.from([
  {"ID" : 1 , "SchoolCode": "A150", "UserID": 1 }, 
  {"ID" : 5 , "SchoolCode": "A140" , "UserID": 4}, 
  {"ID" : 9 , "SchoolCode": "C140" , "UserID": 3}
]);
const userObs = Rx.Observable.from([
  {"ID" : 1, "Name": "Rick" , "FamilyName": "Grimes" },
  {"ID" : 3, "Name": "Tom" , "FamilyName": "Cruise" },
  {"ID" : 4, "Name": "Amy" , "FamilyName": "Poehler" }
]);
function getUser(userID) {
  return userObs.filter(user => user.ID === userID);
}
studentObs
  .switchMap(student => {
     return getUser(student.UserID).map(user => {
       return Object.assign(student, {user: user});
     })
  })
  .subscribe(val => console.log(val));
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
vincedopro
0viewers