-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
join
method to combine maybes
It is common to have two "maybe streams" of logic that need to be merged together. We could add to the `or` method by providing an `and` method to allow this, but there are cases where the user will want to control how the merge happens. In the case of `and`, the merge will be "take the right side". In the case of `or`, the merge will be "take the left side". It is possible to define other logical operators, though those will also result in "take the {x} side" under various other conditions. Having `join` allows `and`-like conditions with a genericized merge method. It may be worth considering a higher abstraction over `join` in the future that will allow control over both the `merge` and the `conditions`. I imagine something like: ```typescript const x = some('thing'); const y = some('other thing'); const z = x.joinIf( other => other.length > 5, (a, b) => a + b, ); ```
- Loading branch information
Showing
5 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters