I wrote my own litany before opening the article ...
I must not mock.
Mocks are the mind-killer.
Mocks are the little-death that brings total system failure.
I will fully implement my tests.
I will permit the tests to pass over me and through me.
And when the tests have passed, I will turn the inner eye to see their path.
Where the mocks have gone there will be nothing. Only green will remain.
Program to abstractions with clear contracts. Advice since the 1950s.
Why do you folks continue to resist?
How does this library handle control flow? For example, how can I fetch results from the DB, then for each result, execute one of several different pipelines depending on properties of that entity?
You can handle complex branching using standard JavaScript. Since every pipeline is just a function returning data, you can use if/else or map to return different sub-pipelines and commands from within your logic functions. Here's an example:
const processUsersFlow = () =>
effectPipe(
fetchAllUsers,
(users) => {
const tasks = users.map(user => {
if (user.isAdmin) return syncAdminPermissions(user); // Sub-pipeline
if (user.isGuest) return cleanupGuestAccount(user); // Sub-pipeline
return notifyUser(user); // Simple Command
});
return Parallel(tasks);
}
)();
Programming
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev