Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var CloudController = {
- getInfo: function() {
- console.log('get infomation');
- return new Promise(function(reslove, reject) {
- setTimeout(function() {
- reslove({
- authorization_endpoint: ''
- });
- }, 0);
- });
- }
- }
- var UsersUAA = {
- login: function(username, password) {
- console.log('login with ' + username);
- return new Promise(function(reslove, reject) {
- setTimeout(function() {
- reslove('');
- }, 0);
- });
- },
- setEndPoint: function() { }
- }
- var Apps = {
- getApps: function() {
- console.log('get applications');
- return new Promise(function(reslove, reject) {
- setTimeout(function() {
- reslove('got apps');
- }, 0);
- });
- },
- setToken: function() {}
- };
- var username = 'tiven',
- password = 'password';
- function* getCloudApps() {
- console.log('start get cloud apps')
- var result = yield CloudController.getInfo();
- UsersUAA.setEndPoint(result.authorization_endpoint);
- result = yield UsersUAA.login(username, password);
- Apps.setToken(result);
- yield Apps.getApps();
- }
- var cloudApps = getCloudApps();
- cloudApps.next().value.then(function(result) {
- cloudApps.next(result).value.then(function(result) {
- cloudApps.next(result).value.then(function(result) {
- console.log(result);
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement