Last active
February 26, 2020 15:11
-
-
Save b2977053/ebb884d19339e4f571cf2ff42a7c2124 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//Creation Operator - from 輸入陣列 or 字串 or Promise 物件 | |
var arr = ['Jerry', 'Anna', 2016, 2017, '30 days'] | |
var source = Rx.Observable.from(arr); | |
source.subscribe({ | |
next: function(value) { | |
console.log(value) | |
}, | |
complete: function() { | |
console.log('complete!'); | |
}, | |
error: function(error) { | |
console.log(error) | |
} | |
}); | |
// Jerry | |
// Anna | |
// 2016 | |
// 2017 | |
// 30 days | |
// complete! | |
//------------------------ | |
var source = Rx.Observable.from('Word'); | |
source.subscribe(console.log); | |
// W | |
// o | |
// r | |
// d | |
//Promise 物件 | |
//(這裡也可以用 fromPromise ,會有相同的結果。) | |
var source = Rx.Observable.from(new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve('Hello RxJS!'); | |
},3000) | |
})) | |
//promise | |
https://cythilya.github.io/2018/10/31/promise/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment