Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3 #377

Closed
wants to merge 105 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
b07fe0d
upgrade: remove `vendor` and bump go to `v1.18` to support generics
si3nloong Aug 22, 2022
4a10a56
refactor: observable API using generic
si3nloong Aug 27, 2022
a6ed0a5
fix: CI
si3nloong Aug 29, 2022
fc52b6b
fix: golangci-lint
si3nloong Aug 29, 2022
bf2b5da
refactor: rework observable API using generics, added `Take`, `Filter…
si3nloong Aug 29, 2022
07da982
chore: add more operators
si3nloong Aug 29, 2022
c22b157
chore: allow count to be generic
si3nloong Aug 29, 2022
b3af599
fix: defer unsubscribe to prevent dangling channel
si3nloong Aug 29, 2022
4e04e78
chore: add comments
si3nloong Aug 29, 2022
21ef76a
fix: types
si3nloong Aug 29, 2022
2e96aff
chore: added `ConcatMap` API
si3nloong Aug 30, 2022
0e9af5b
chore: rename files
si3nloong Aug 30, 2022
8ef339c
fix: test (disable the old debounce testing)
si3nloong Aug 30, 2022
ec0beba
fix: send data on closed channel
si3nloong Aug 31, 2022
c9b9050
chore: add operator `ToArray`
si3nloong Aug 31, 2022
7a8b2c7
fix: tests
si3nloong Aug 31, 2022
a0d2f2b
chore: added test cases
si3nloong Aug 31, 2022
e0b8696
chore: added new operator `Count`
si3nloong Aug 31, 2022
ae81537
chore: add new operator `Skip` and fix `ElementAt` operator bug
si3nloong Sep 1, 2022
23b26b8
✅ test: added test cases
si3nloong Sep 1, 2022
64e8d22
🧪 test: added more tests
si3nloong Sep 1, 2022
01ae82b
chore: add `Tap` and `Timestamp` operator
si3nloong Sep 1, 2022
4de9202
🐛 fix: `consumeStreamUntil` bug, it shouldn't call `Complete` if erro…
si3nloong Sep 1, 2022
45591de
refactor: use embedded struct for `safeSubscriber`
si3nloong Sep 4, 2022
73ca684
chore: added `Done` to notification, added `Some` and `None` nomad
si3nloong Sep 4, 2022
4e014c4
♻️ refactor: stream structure
si3nloong Sep 5, 2022
ebc35d5
fix: test
si3nloong Sep 6, 2022
6c003c3
chore: disable random leak test
si3nloong Sep 6, 2022
8d7f2f4
fix: operator `DistinctUntilChanged`
si3nloong Sep 6, 2022
98050c9
test: added tests and added `TimeInterval`
si3nloong Sep 6, 2022
aadf897
refactor: rename `Data` to `Notification`
si3nloong Sep 6, 2022
b45d53c
fix: test
si3nloong Sep 6, 2022
f68955a
fix: `ConcatMap` business logic
si3nloong Sep 8, 2022
761c9d5
fix: don't send on closed channel
si3nloong Sep 8, 2022
0668d58
fix: timestamp should be UTC
si3nloong Sep 8, 2022
6518064
🐛 fix: test
si3nloong Sep 8, 2022
3f0ade3
fix: `golangci-lint` failed on `windows` (https://github.com/golangci…
si3nloong Sep 8, 2022
ac12383
chore: downgrade `golangci-lint`
si3nloong Sep 8, 2022
096e672
✅ test: add more tests and fix some minor bugs
si3nloong Sep 8, 2022
f5209d2
🧪 test: added more tests
si3nloong Sep 8, 2022
f8c9ba8
chore: some updates
si3nloong Sep 8, 2022
854e634
feat: updated new API and deprecated old API
si3nloong Sep 9, 2022
367260c
refactor: codes
si3nloong Sep 9, 2022
db15c72
refactor: filter and skip operation
si3nloong Sep 9, 2022
bfcab71
feat: finish `DebounceTime` and `ThrottleTime` API
si3nloong Sep 10, 2022
1c412a4
feat: introduce join operators, `ForkJoin` and `Zip`
si3nloong Sep 10, 2022
f264b49
chore: drafting `GroupedObservable` and `CombineLatest`
si3nloong Sep 10, 2022
77b3a72
feat: added `Timeout`
si3nloong Sep 11, 2022
4470ff7
fix: `CombineLatestWith` API and added `Timeout` API
si3nloong Sep 12, 2022
f9d144e
chore: set minimum to go 1.19 and comment old codes
si3nloong Sep 12, 2022
f5d0951
chore: bump `golangci-lint`
si3nloong Sep 12, 2022
09fcae3
fix: test
si3nloong Sep 12, 2022
28f5d0c
fix: `Timeout`
si3nloong Sep 12, 2022
de94dcf
chore: temporary disable `Timeout` test
si3nloong Sep 12, 2022
94940b2
fix: `Timeout` operator
si3nloong Sep 12, 2022
5ee5dd1
chore: added `ExhaustMap` operator
si3nloong Sep 12, 2022
19b1df7
fix: transformation operators
si3nloong Sep 12, 2022
6b5b753
chore: added `ThrowError`, `CatchError`, and `ThrowIfEmpty` operators
si3nloong Sep 13, 2022
257857c
doc: update `README`
si3nloong Sep 13, 2022
755263d
chore: added `Single` operator
si3nloong Sep 14, 2022
7ee4be1
chore: working on `Buffer` API
si3nloong Sep 15, 2022
52ab1c9
fix: `Zip` actual behaviour
si3nloong Sep 17, 2022
afcb3a5
chore: bump `go.mod`
si3nloong Sep 17, 2022
d9f4040
chore: added `Dematerialize` API
si3nloong Sep 17, 2022
f2e32d5
chore: added `Sample` API
si3nloong Sep 17, 2022
740679b
fix: `Repeat` and `Retry`
si3nloong Sep 17, 2022
2cde193
fix: `Defer`, `Retry`, `Repeat` and `ZipWith`
si3nloong Sep 17, 2022
db76f67
🐛 fix: `ZipWith` and `ZipAll`
si3nloong Sep 18, 2022
5800968
chore: fix `Audit` API
si3nloong Sep 18, 2022
29a4fd0
doc: update `README`
si3nloong Sep 18, 2022
f8ee7b1
fix: timeout on CI
si3nloong Sep 18, 2022
35b0014
refactor: rename some function name based on ReactiveX standard
si3nloong Sep 21, 2022
acd52ca
fix: test
si3nloong Sep 21, 2022
614e1e0
refactor: rename functions
si3nloong Sep 21, 2022
bbca89a
fix: test
si3nloong Sep 21, 2022
581c28c
chore: complete `ConcatWith` API
si3nloong Sep 21, 2022
d98490d
fix: several operators, such as `ForkJoin`, `CombineLatestAll`, `Comb…
si3nloong Sep 22, 2022
50a32b9
chore: complete `SequenceEqual` API
si3nloong Sep 22, 2022
991eed6
docs: update API documentation
si3nloong Sep 22, 2022
b353f09
docs: update `README`s
si3nloong Sep 22, 2022
b7e4aa9
fix: golangci-lint error
si3nloong Sep 22, 2022
c03c693
test: add tests
si3nloong Sep 23, 2022
723bd14
refactor: change `Optional` to interface instead and add some tests
si3nloong Sep 26, 2022
516db52
fix: `BufferCount` and update documentations
si3nloong Sep 26, 2022
7cbdb1d
chore: update `RaceWith` API and add new function `IsEnd` to `Observa…
si3nloong Oct 2, 2022
fe40c54
docs: update `README`
si3nloong Oct 2, 2022
b381207
docs: update `README` and fix test
si3nloong Oct 2, 2022
13d30b8
docs: update documentation
si3nloong Oct 3, 2022
8aec543
fix: test
si3nloong Oct 3, 2022
58ccc46
docs: update API documentation
si3nloong Oct 17, 2022
17080c6
docs: update docs
si3nloong Oct 17, 2022
0fdf245
fix: test
si3nloong Oct 17, 2022
cb9eca3
docs: update `README`
si3nloong Oct 17, 2022
0696952
docs: update documentation
si3nloong Oct 24, 2022
8a7e1e4
fix: optional and added documentation
si3nloong Oct 25, 2022
4ce2df5
chore: upgrade `golangci-lint`
si3nloong Oct 25, 2022
31c13ab
chore: add APIs
si3nloong Oct 27, 2022
c657d5d
fix: catch
si3nloong Oct 27, 2022
5425ffd
fix: CI
si3nloong Oct 27, 2022
6ee6b6a
docs: update API documentation
si3nloong Oct 27, 2022
54023b4
chore: update
si3nloong Oct 27, 2022
6fc0cfc
chore: remove old code
si3nloong Oct 27, 2022
ff33b14
docs: update `README`
si3nloong Oct 27, 2022
3bbb929
fix: test
si3nloong Oct 27, 2022
a806540
fix: documentation
si3nloong Oct 27, 2022
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
14 changes: 9 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ jobs:
test:
strategy:
matrix:
go-version: [1.15.x, 1.16.x]
go-version: [1.19.x]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v3.2.0
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/[email protected]
uses: actions/checkout@v3

- name: Linting
uses: golangci/golangci-lint-action@v2.5.2
uses: golangci/golangci-lint-action@v3
with:
version: v1.29
version: v1.50.1
args: --timeout=3m --issues-exit-code=0 ./...

- name: test
run: make test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ node_modules
# IntelliJ
.idea
*.iml
.realize.yaml
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.formatOnSave": true,
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 80
}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test:
go clean -testcache ./...
go test -race -timeout 10s ./... --tags=all
go test -timeout 10s -run TestLeak
go test -race -timeout 15s ./... --tags=all
go test -timeout 15s -run TestLeak
223 changes: 103 additions & 120 deletions README.md

Large diffs are not rendered by default.

129 changes: 129 additions & 0 deletions aggregate_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package rxgo

import (
"errors"
"testing"
)

func TestCount(t *testing.T) {
t.Run("Count with Empty", func(t *testing.T) {
checkObservableResult(t, Pipe1(Empty[any](), Count[any]()), uint(0), nil, true)
})

t.Run("Count everything from Range(0,7)", func(t *testing.T) {
checkObservableResult(t, Pipe1(Range[uint](0, 7), Count[uint]()), uint(7), nil, true)
})

t.Run("Count from Range(1,7) with condition", func(t *testing.T) {
checkObservableResult(t, Pipe1(Range[uint](1, 7), Count(func(i uint, _ uint) bool {
return i%2 == 1
})), uint(4), nil, true)
})
}

type human struct {
age int
name string
}

func TestMax(t *testing.T) {
t.Run("Max with Empty", func(t *testing.T) {
checkObservableResult(t, Pipe1(
Empty[any](),
Max[any](),
), nil, nil, true)
})

t.Run("Max with numbers", func(t *testing.T) {
checkObservableResult(t, Pipe1(
Of2[uint](5, 4, 7, 2, 8),
Max[uint](),
), uint(8), nil, true)
})

t.Run("Max with struct", func(t *testing.T) {
checkObservableResult(t, Pipe1(
Scheduled(
human{age: 7, name: "Foo"},
human{age: 5, name: "Bar"},
human{age: 9, name: "Beer"},
),
Max(func(a, b human) int8 {
if a.age < b.age {
return -1
}
return 1
}),
), human{age: 9, name: "Beer"}, nil, true)
})
}

func TestMin(t *testing.T) {
t.Run("Min with Empty", func(t *testing.T) {
checkObservableResult(t, Pipe1(Empty[any](), Min[any]()), nil, nil, true)
})

t.Run("Min with numbers", func(t *testing.T) {
checkObservableResult(t, Pipe1(Scheduled[uint](5, 4, 7, 2, 8), Min(func(a, b uint) int8 {
if a < b {
return -1
}
return 1
})), uint(2), nil, true)
})

t.Run("Min with struct", func(t *testing.T) {
checkObservableResult(t, Pipe1(Scheduled(
human{age: 7, name: "Foo"},
human{age: 5, name: "Bar"},
human{age: 9, name: "Beer"},
), Min(func(a, b human) int8 {
if a.age < b.age {
return -1
}
return 1
})), human{age: 5, name: "Bar"}, nil, true)
})
}

func TestReduce(t *testing.T) {
t.Run("Reduce with Empty", func(t *testing.T) {
checkObservableResult(t, Pipe1(
Empty[uint](),
Reduce(func(acc, cur, _ uint) (uint, error) {
return acc + cur, nil
}, 0),
), uint(0), nil, true)
})

t.Run("Reduce with error", func(t *testing.T) {
var err = errors.New("something happened")
checkObservableResult(t, Pipe1(
Range[uint](1, 18),
Reduce(func(acc, cur, idx uint) (uint, error) {
if idx > 5 {
return 0, err
}
return acc + cur, nil
}, 0),
), uint(0), err, false)
})

t.Run("Reduce with values", func(t *testing.T) {
checkObservableResult(t, Pipe1(
Range[uint](1, 18),
Reduce(func(acc, cur, idx uint) (uint, error) {
return acc + cur, nil
}, 0),
), uint(171), nil, true)
})

t.Run("Reduce with zero default value", func(t *testing.T) {
checkObservableResult(t, Pipe1(
Scheduled[uint](1, 3, 5),
Reduce(func(acc, cur, _ uint) (uint, error) {
return acc + cur, nil
}, 0),
), uint(9), nil, true)
})
}
12 changes: 6 additions & 6 deletions assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ func IsNotEmpty() RxAssert {
})
}

// IsEmpty checks that the observable has not produce any item.
func IsEmpty() RxAssert {
return newAssertion(func(a *rxAssert) {
a.checkHasNoItems = true
})
}
// // IsEmpty checks that the observable has not produce any item.
// func IsEmpty() RxAssert {
// return newAssertion(func(a *rxAssert) {
// a.checkHasNoItems = true
// })
// }

// HasError checks that the observable has produce a specific error.
func HasError(err error) RxAssert {
Expand Down
Loading