Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- **Breaking:** `AwaitOperationConfiguration` cases are prefixed with `Await` (`AwaitSequential`, `AwaitParallel 4`, ...) so they no longer collide with `System.Threading.Tasks.Parallel`
- **Breaking:** `rxquery` `sumBy` adds values of the projected type: it requires `(+) : 'Value * 'Value -> 'Value`
- `mapAsync` and `iterAsync` validate the concurrency limit of the options when they are called

### Fixed

- `rxquery` emitted its elements on the thread pool, out of order and after the source had moved on; `yield` and `zero` are now synchronous
- `rxquery` `sumBy` passed `null` to the `(+)` of reference types

## [0.3.1] - 2026-01-28

Expand Down
14 changes: 12 additions & 2 deletions src/FSharp.Control.R3/Observable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,20 @@ module Builders =
member _.MinBy (s : Observable<'a>, [<ProjectionParameter>] valueSelector : 'a -> 'b) = s.MinByAsync (new Func<'a, 'b> (valueSelector))

[<CustomOperation("sumBy")>]
member inline _.SumBy (s : Observable<_>, [<ProjectionParameter>] valueSelector : _ -> _) =
member inline _.SumBy (s : Observable<_>, [<ProjectionParameter>] valueSelector : _ -> 'Value) =
// The first element seeds the sum: seeding with Unchecked.defaultof passed null to the (+) of reference types,
// while requiring a Zero member would reject types such as TimeSpan whose zero is a field
s
|> _.Select(valueSelector)
|> _.AggregateAsync(Unchecked.defaultof<_>, new Func<_, _, _> (fun a b -> a + b))
|> _.AggregateAsync(
ValueNone,
new Func<_, _, _> (fun sum value ->
match sum with
| ValueNone -> ValueSome value
| ValueSome sum -> ValueSome (sum + value)
),
new Func<_, _> (ValueOption.defaultValue Unchecked.defaultof<'Value>)
)

[<CustomOperation("zip", IsLikeZip = true)>]
member _.Zip (s1 : Observable<_>, s2 : Observable<_>, [<ProjectionParameter>] resultSelector : _ -> _) =
Expand Down