Created
April 27, 2017 18:32
-
-
Save Ibro/79afa5dfe7d9df90bfffca69282ac35f to your computer and use it in GitHub Desktop.
Promise and Observable - Coding Blast - www.codingblast.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Observable} from 'rxjs'; | |
let promise = new Promise((resolve, reject) => { | |
console.log('Promise starts'); | |
setTimeout(() => { | |
resolve('Promise - after timeout of 1500 miliseconds!'); | |
}, 1500); | |
}); | |
let source = Observable.create((observer) => { | |
console.log('Observable starts'); | |
setTimeout(() => { | |
observer.next('Observable - after timeout of 1500 miliseconds!'); | |
}, 1500); | |
}); | |
source.subscribe(function next(value) { | |
console.log('in next, value: ', value); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment