You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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,
);
```
0 commit comments