The lazy map intuition you provide here is the basis of many o' functor and it's crystal clear. Promises and Observables are spot on for async FP and cover the cases most people ever need.
Again, no tech errors, just some thoughts:
"In fact, the same concern could apply to record being present before onCustomer(..) is specified to receive it".
Initially, I started looking for a record variable somewhere. I'm pretty sure you were referring to the customerRecord var from the previous example or just the response in customerPromise in general, but it took a second.
I wonder if it's worthwhile to mention map is literally compose in a lazy setting: Observable.map(f) = compose(f, this.fn) (or alternatively exploiting the church encoding to pushing into an array for a perf benefit). This, not only fuses the maps into 1 pass, but also keeps us pure since we're merely building a computation.
Speaking of which, one notable omission and I'm not sure if you are purposefully avoiding it since this is "fp-lite", but laziness is exactly how we keep our programs pure since nothing actually happens until we get to the caller.
I was surprised when I read: It's not necessary to assign the observable to b and then call b.subscribe(..) separately from the chain; that's only done to reinforce that each operator returns a new observable from the previous one because, fp'ers do that very much on purpose to keep b pure - had subscribe() been at the end of the chain, b would lose its purity.
That's really it. Do with that what you will :) I'm just throwing in my two cents.
Another great chapter with 0 tech issues.
The lazy
map
intuition you provide here is the basis of many o' functor and it's crystal clear. Promises and Observables are spot on for async FP and cover the cases most people ever need.Again, no tech errors, just some thoughts:
record
being present beforeonCustomer(..)
is specified to receive it".Initially, I started looking for a
record
variable somewhere. I'm pretty sure you were referring to thecustomerRecord
var from the previous example or just the response incustomerPromise
in general, but it took a second.I wonder if it's worthwhile to mention
map
is literallycompose
in a lazy setting:Observable.map(f) = compose(f, this.fn)
(or alternatively exploiting the church encoding to pushing into an array for a perf benefit). This, not only fuses the maps into 1 pass, but also keeps us pure since we're merely building a computation.Speaking of which, one notable omission and I'm not sure if you are purposefully avoiding it since this is "fp-lite", but laziness is exactly how we keep our programs pure since nothing actually happens until we get to the caller.
I was surprised when I read:
It's not necessary to assign the observable to b and then call b.subscribe(..) separately from the chain; that's only done to reinforce that each operator returns a new observable from the previous one
because, fp'ers do that very much on purpose to keepb
pure - hadsubscribe()
been at the end of the chain,b
would lose its purity.That's really it. Do with that what you will :) I'm just throwing in my two cents.