func FromChanInt(ch <-chan int) ObservableInt {
	observable := func(observe IntObserver, scheduler Scheduler, subscriber Subscriber) {
		cancel := make(chan struct{})
		runner := scheduler.ScheduleRecursive(func(self func()) {
			if !subscriber.Subscribed() {
				return
			}
			select {
			case next, ok := <-ch:
				if !subscriber.Subscribed() {
					return
				}
				if ok {
					observe(next, nil, false)
					if !subscriber.Subscribed() {
						return
					}
					self()
				} else {
					var zero int
					observe(zero, nil, true)
				}
			case <-cancel:
				return
			}
		})
		subscriber.OnUnsubscribe(func() {
			runner.Cancel()
			close(cancel)
		})
	}
	return observable
}
jig:name FromChanInt
FromChanInt creates an ObservableInt from a Go channel of int values.
It's not possible for the code feeding into the channel to send an error.
The feeding code can send nil or more int items and then closing the
channel will be seen as completion.
package RefCount
import (
	"math"
	"runtime"
	"sync"
	"sync/atomic"
	"time"
	"github.com/reactivego/scheduler"
	"github.com/reactivego/subscriber"
)
type Scheduler = scheduler.Scheduler
func GoroutineScheduler() Scheduler {
	return scheduler.Goroutine
}
type Subscriber = subscriber.Subscriber
type IntObserver func(next int, err error, done bool)
type ObservableInt func(IntObserver, Scheduler, Subscriber)
func IntervalInt(interval time.Duration) ObservableInt {
	observable := func(observe IntObserver, subscribeOn Scheduler, subscriber Subscriber) {
		i := 0
		runner := subscribeOn.ScheduleFutureRecursive(interval, func(self func(time.Duration)) {
			if subscriber.Subscribed() {
				observe(int(i), nil, false)
				i++
				if subscriber.Subscribed() {
					self(interval)
				}
			}
		})
		subscriber.OnUnsubscribe(runner.Cancel)
	}
	return observable
}