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
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!