Passionate, positive-minded, Sr Front-end Eng @ Preply (Design System) / Advisor @ Plannix / ex platform team / ex team leader / Speaker / Instructor / Writer / Remote worker
Location
Lecco, Italy
Education
Bachelor's degree, Communication design - High School Diploma, Informatic Technologies
Pronouns
he/him
Work
Senior Front-end Engineer/Tech lead at Preply (Design System)
Hey Matt, replacing ALL the services with invoked callbacks (even a simple fetch that returns a promise) has only one "weak" point: testing. If I'm correct, mocking services is handy with withConfig, while for callbacks I must mock the imported and consumed module, right?
So told: I know that callbacks have superior Typescript experience and it's all about the trade-offs 😊
And thanks, I love the clarity of your articles
Passionate, positive-minded, Sr Front-end Eng @ Preply (Design System) / Advisor @ Plannix / ex platform team / ex team leader / Speaker / Instructor / Writer / Remote worker
Location
Lecco, Italy
Education
Bachelor's degree, Communication design - High School Diploma, Informatic Technologies
Pronouns
he/him
Work
Senior Front-end Engineer/Tech lead at Preply (Design System)
Hey Matt, replacing ALL the services with invoked callbacks (even a simple fetch that returns a promise) has only one "weak" point: testing. If I'm correct, mocking services is handy with
withConfig, while for callbacks I must mock the imported and consumed module, right?So told: I know that callbacks have superior Typescript experience and it's all about the trade-offs 😊
And thanks, I love the clarity of your articles
You can mock invoked callbacks in exactly the same way as with services! Use a named service and then mock it in the same way.
See the 'Event Listeners' example
My bad, sorry 🙏 thanks Matt!