Skip to content

Commit

Permalink
Documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
teivah committed Feb 23, 2020
1 parent 3e33ec9 commit ff2a4c5
Show file tree
Hide file tree
Showing 69 changed files with 2,948 additions and 3,022 deletions.
49 changes: 49 additions & 0 deletions doc/all.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# All Operator

## Overview

Determine whether all items emitted by an Observable meet some criteria.

![](http://reactivex.io/documentation/operators/images/all.png)

## Example

```go
observable := rxgo.Just([]interface{}{1, 2, 3, 4}).
All(func(i interface{}) bool {
// Check all items are less than 10
return i.(int) < 10
})
```

Output:

```
true
```

## Options

### WithBufferedChannel

[Detail](options.md#withbufferedchannel)

### WithContext

[Detail](options.md#withcontext)

### WithObservationStrategy

[Detail](options.md#withobservationstrategy)

### WithErrorStrategy

[Detail](options.md#witherrorstrategy)

### WithPool

https://github.com/ReactiveX/RxGo/wiki/Options#withpool

### WithCPUPool

https://github.com/ReactiveX/RxGo/wiki/Options#withcpupool
48 changes: 48 additions & 0 deletions doc/amb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Amb Operator

## Overview

Given two or more source Observables, emit all of the items from only the first of these Observables to emit an item.

![](http://reactivex.io/documentation/operators/images/amb.png)

## Example

```go
observable := rxgo.Amb([]rxgo.Observable{
rxgo.Just([]interface{}{1, 2, 3}),
rxgo.Just([]interface{}{4, 5, 6}),
})
```

Output:

```
1
2
3
```
or
```
4
5
6
```

## Options

### WithBufferedChannel

[Detail](options.md#withbufferedchannel)

### WithContext

[Detail](options.md#withcontext)

### WithObservationStrategy

[Detail](options.md#withobservationstrategy)

### WithErrorStrategy

[Detail](options.md#witherrorstrategy)
55 changes: 55 additions & 0 deletions doc/average.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Average Operator

## Overview

Calculate the average of numbers emitted by an Observable and emits this average.

![](http://reactivex.io/documentation/operators/images/average.png)

## Instances

* `AverageFloat32`
* `AverageFloat64`
* `AverageInt`
* `AverageInt8`
* `AverageInt16`
* `AverageInt32`
* `AverageInt64`

## Example

```go
observable := rxgo.Just([]interface{}{1, 2, 3, 4}).AverageInt()
```

Output:

```
2
```

## Options

### WithBufferedChannel

[Detail](options.md#withbufferedchannel)

### WithContext

[Detail](options.md#withcontext)

### WithObservationStrategy

[Detail](options.md#withobservationstrategy)

### WithErrorStrategy

[Detail](options.md#witherrorstrategy)

### WithPool

https://github.com/ReactiveX/RxGo/wiki/Options#withpool

### WithCPUPool

https://github.com/ReactiveX/RxGo/wiki/Options#withcpupool
54 changes: 54 additions & 0 deletions doc/backoffretry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# BackOffRetry Operator

## Overview

Implements a backoff retry if a source Observable sends an error, resubscribe to it in the hopes that it will complete without error.

The backoff configuration relies on [github.com/cenkalti/backoff/v4](github.com/cenkalti/backoff/v4).

![](http://reactivex.io/documentation/operators/images/retry.png)

## Example

```go
// Backoff retry configuration
backOffCfg := backoff.NewExponentialBackOff()
backOffCfg.InitialInterval = 10 * time.Millisecond

observable := rxgo.Defer([]rxgo.Producer{func(ctx context.Context, next chan<- rxgo.Item, done func()) {
next <- rxgo.Of(1)
next <- rxgo.Of(2)
next <- rxgo.Error(errors.New("foo"))
done()
}}).BackOffRetry(backoff.WithMaxRetries(backOffCfg, 2))
```

Output:

```
1
2
1
2
1
2
foo
```

## Options

### WithBufferedChannel

[Detail](options.md#withbufferedchannel)

### WithContext

[Detail](options.md#withcontext)

### WithObservationStrategy

[Detail](options.md#withobservationstrategy)

### WithErrorStrategy

[Detail](options.md#witherrorstrategy)
98 changes: 98 additions & 0 deletions doc/buffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Buffer Operator

## Overview

Periodically gather items emitted by an Observable into bundles and emit these bundles rather than emitting the items one at a time

![](http://reactivex.io/documentation/operators/images/Buffer.png)

## Instances

* `BufferWithCount`:

![](http://reactivex.io/documentation/operators/images/bufferWithCount3.png)

```go
observable := rxgo.Just([]interface{}{1, 2, 3, 4}).BufferWithCount(3)
```

Output:

```
1 2 3
4
```

* `BufferWithTime`:

![](http://reactivex.io/documentation/operators/images/bufferWithTime5.png)

```go
// Create the producer
ch := make(chan rxgo.Item, 1)
go func() {
i := 0
for range time.Tick(time.Second) {
ch <- rxgo.Of(i)
i++
}
}()

observable := rxgo.FromChannel(ch).
BufferWithTime(rxgo.WithDuration(3*time.Second), nil)
```

Output:

```
0 1 2
3 4 5
6 7 8
...
```

* `BufferWithTimeOrCount`:

![](http://reactivex.io/documentation/operators/images/bufferWithTimeOrCount6.png)

```go
// Create the producer
ch := make(chan rxgo.Item, 1)
go func() {
i := 0
for range time.Tick(time.Second) {
ch <- rxgo.Of(i)
i++
}
}()

observable := rxgo.FromChannel(ch).
BufferWithTimeOrCount(rxgo.WithDuration(3*time.Second), 2)
```

Output:

```
0 1
2 3
4 5
...
```

## Options

### WithBufferedChannel

[Detail](options.md#withbufferedchannel)

### WithContext

[Detail](options.md#withcontext)

### WithObservationStrategy

[Detail](options.md#withobservationstrategy)

### WithErrorStrategy

[Detail](options.md#witherrorstrategy)
Loading

0 comments on commit ff2a4c5

Please sign in to comment.