Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. var CloudController = {
  2. getInfo: function() {
  3. console.log('get infomation');
  4. return new Promise(function(reslove, reject) {
  5. setTimeout(function() {
  6. reslove({
  7. authorization_endpoint: ''
  8. });
  9. }, 0);
  10. });
  11. }
  12. }
  13.  
  14. var UsersUAA = {
  15. login: function(username, password) {
  16. console.log('login with ' + username);
  17. return new Promise(function(reslove, reject) {
  18. setTimeout(function() {
  19. reslove('');
  20. }, 0);
  21. });
  22. },
  23. setEndPoint: function() { }
  24. }
  25.  
  26. var Apps = {
  27. getApps: function() {
  28. console.log('get applications');
  29. return new Promise(function(reslove, reject) {
  30. setTimeout(function() {
  31. reslove('got apps');
  32. }, 0);
  33. });
  34. },
  35. setToken: function() {}
  36. };
  37.  
  38. var username = 'tiven',
  39. password = 'password';
  40.  
  41. function* getCloudApps() {
  42. console.log('start get cloud apps')
  43. var result = yield CloudController.getInfo();
  44. UsersUAA.setEndPoint(result.authorization_endpoint);
  45. result = yield UsersUAA.login(username, password);
  46. Apps.setToken(result);
  47. yield Apps.getApps();
  48. }
  49.  
  50. var cloudApps = getCloudApps();
  51.  
  52. cloudApps.next().value.then(function(result) {
  53. cloudApps.next(result).value.then(function(result) {
  54. cloudApps.next(result).value.then(function(result) {
  55. console.log(result);
  56. });
  57. });
  58. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement