Skip to content

Instantly share code, notes, and snippets.

@Ibro
Created April 27, 2017 18:32
Show Gist options
  • Save Ibro/79afa5dfe7d9df90bfffca69282ac35f to your computer and use it in GitHub Desktop.
Save Ibro/79afa5dfe7d9df90bfffca69282ac35f to your computer and use it in GitHub Desktop.
Promise and Observable - Coding Blast - www.codingblast.com
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