Pipe Functions and Compose Functions | Javascript Functional Programming Tutorial

preview_player
Показать описание

Learn how to create pipe functions and compose functions in this Javascript functional programming tutorial. Functional programming needs small pure functions to work together through composition or pipelining. This advanced Javascript tutorial will help you learn through several examples.

Functional Programming with Javascript Tutorials:

Pipe Functions and Compose Functions | Javascript Functional Programming Tutorial

(00:00) Intro
(0:32) What are compose and pipe functions?
(3:03) Creating a compose function
(5:31) Creating a pipe function
(6:56) Adding a function with multiple parameters
(9:30) Example: a word count function
(11:14) Nested pipe function example: palindrome checks
(13:08) Adding clone / copy functions to compose / pipe
(13:59) Example 1: Clone function before impure function
(17:04) Example 2: Curry the function for a partial that is unary
(19:29) Example 3: Insert the clone function as a dependency

✅ Follow Me:

Was this tutorial about Pipe Functions and Compose Functions for Functional Programming in Javascript helpful? If so, please share. Let me know your thoughts in the comments.

#functional #programming #javascript
Рекомендации по теме
Комментарии
Автор

just considered Subscribed!
after watching lots of your series, it boosted my javascript skills like never before. Please Teach Us More Sir!!!

adimardev
Автор

You’re a fantastic teacher! Doing a great job with your lights on the intro by the way. I actually think that you might benefit from showing a face cam, I know it’s kinda taboo among developer channels but I believe that seeing a teacher’s face helps with teaching and retention. Just my opinion. I agree with others that I’d love to see a non trivial example or two where I can see how this approach really helps in production. Or even a link to an exercise that I could do that involves piping as the most elegant approach. For example, I have learned about currying in the past but it’s always just thrown in as a “oh you can do that” and it sneaks it’s way in without being called out in a lot of libraries like higher order components in react. That leads to me using the pattern without being able to implement it myself. Seeing some real examples could help, kinda like how if I was learning about cars, I would want to learn about an engine and then go racing in it to enjoy it and really cement that experience in the real world. Still love the channel. Please keep making videos 😄

JakeHaugen
Автор

the time you dedicated to build these contents are worth, no doubt about that, these videos helps lot, thanks

dylanm
Автор

Dave Dave; you did it again thanks for the detail and all the help! I mean, man it really helps...
I can hear Eddie in the background playing 'Eruption' right now, cuz it finally 'Clicked'
Must have been how he felt when he first discovered his 'tapping' technique lol...

gordonmullen
Автор

Arguments- the values (variables) you pass to a function when calling it
Parameters- the values (variables) you state in the function definition

urjithemantdesai
Автор

Very practical,
It's easier for me to work with pipe functions as it goes with the reading direction, although I'm natively rtl reader🙄,
the Currying approach looks cleaner and very organized,

one question just came to my mind, what if we needed a way to break the execution chain at some point due to an error or a business logic requirement?
- maybe throwing an error and then catch it on the calling context,
- or wrapping the piping/composing function with another function that accepts an optional error callback function, - or maybe just making use of a Promise instead but this may add extra complexity layer
- or dispatching a custom event

anyway, sometimes I'm overthinking about simple things

Great video as expected.
Thanks Dave

ahmad-murery
Автор

Great explanations in this video. Hands on and applicable. Very well thought out. Subscribed to your channel.

paulhammond
Автор

wonderful tutorial!! thank you for your sharing very practical examples!!

aya
Автор

Youve covered some really good topics :)

kshitijvengurlekar
Автор

Thanks for the explanation.
For me, both of those topics :
(3:03) Creating a compose function
(5:31) Creating a pipe function,
Including the operators names ("prev", "val", "fn") in the order of which they've been written as arguments,
As well as the entire functions chronicles,
Including the fact that 'pipe' reads from left to right while
Looking quite the same (with minor unexplained differences) -
Specially after the opening example -
That was an overwhelmingly unproportional jump forward.

This entire section is yet definitely unintuitive for me,
Even after rewatching each and every related previous video which you've been referring to.
I watched it all over again, came back, and yet -
Couldn't figure out the concept's resolutions through the chosen function names, and through all the parts which have been presented as obvious.

I've watched this video more than once,
But too many obstacles during it are preventing me from translating your explanation into a coherentive conclusion.

I do appreciate the fact that you put your time and effort though.

shineLouisShine
Автор

excellent guide. The only thing I would add to this is perhaps 2 short examples of when it would be beneficial to instead rely on utility libraries like Lodash or Ramda when working with compose and pipe processes.

kensleylewis
Автор

The youtube cover is not so good, but this video content is awesome and clear.

jimkk
Автор

Thank you so much. Your video is so great. It helps me a lot to understand compose functions. <3

anhnguyennguyen
Автор

Hi @DaveGrayTeachesCode, great video there! I was wondering, instead of passing cloned object, how feasible it will be to use spread operator and/or .map() function within each of the functions in the pipeline. Which one would be more performant or better, per you?

sandeshwar
Автор

Correct me if I am wrong, why not throw a error if splitOnSpace function was not create in 12:00 min in nested pipe.

wallacesansanoski
Автор

Any opinion on things like fp-ts the typescript library for functional programming?

kierrereeg
Автор

Dave, thank you for pipes I did not know these were a thing. But I'm a bit confused at 16:33 on the comparison, I thought they would always return false because it's not referencing the same object in memory, even if the homeScore was 0. This is why lodash has a deep comparison, to compare every property.
I guess I need to do more testing. What am I missing, I just tested this?
const obj1 = { home: 0, away: 0 }
const obj2 = { home: 0, away: 0 }
console.log(obj1 === obj2) // false

avertry
Автор

I guess due to reduce this only really works when you want a single reduceable parameter to be passed between functions. Howeverin a more "real life" example, where an object could be passed between functions (normally done for query purposes) which is not meant to e reduced as a whole normlly... does this approach have any advantages over just stringing the functions async?

andyelgrand
Автор

I am getting this type error.

TypeError: str.split is not a function
at split (/tmp/BNaMPuWsLj.js:4:24)
at /tmp/BNaMPuWsLj.js:1:53
at Array.reduce (<anonymous>)
at /tmp/BNaMPuWsLj.js:1:33
at isStrPalindrome (/tmp/BNaMPuWsLj.js:23:42)
at Object.<anonymous> (/tmp/BNaMPuWsLj.js:25:13)
at Module._compile
at Module._extensions..js
at Module.load
at Module._load

SurajbhanMundotiya-wc
Автор

I wish you could have a complete course in a place like udemy

ИльхомКурбанов-ыэ