This code gives me this error
Warning: a promise was created in a handler but none were returned from it
var Observable = Rx.Observable;
var source = Observable.range(0, 3);
source
.flatMap(item => {
console.log('getting first promise');
return Observable.fromPromise(
new Prom...
@SomeKittens an Rx observable defers a function. I remembered it after talking to Reed at the C# room w.r.t cancellation.
@SomeKittens you're really not, how do you think the average angular dev is going to feel when they find out htey're making two requests instead of one :D ?
It's not really an FP concept - it's just having the concept of manipulating the result of a function without invoking the function. It's like constructing new functions.
Basically, now you wrap things in functions, but it could be interesting to explore a general pattern for what Rx does where it subscribes to invoke the action. It's pretty obvious why Rx requires it (to not miss events and all).
I wonder if we can distil the function object pattern domenic and jafar discuss there and actually generalize it.
The trick is to get the same type of return value. I think this isn't really possible in a dynamic language.
You don't really want a () => T It's harder you want a F<T> where F<T> has all the methods X => Y of F only with signatures X => F<Y>.
Let me be clearer
You want to lift all functions X => Y into F<Y> where F has a function invokeX => Y. So basically lift(f).invoke(x) returns the same as f(x)`. Only F also has all the functions Y does except with the above said altered signatures.
f:: a -> b
lift:: (a -> b) -> (F<a, b>)
invoke:: F<a, b> -> a -> b
compose:: (b -> c) -> (F<a, b> -> F<b, c>)
I guess the correct way to consider "all the functions on a type b" is to just look at "all the functions whose first argument is a b". Which leaves us with drumroll arrows.