1 import rx;
2
3 auto sub = new SubjectObject!int;
4 size_t putCount = 0;
5 size_t disposedCount = 0;
6
7 auto disposable = sub.doSubscribe!(_ => putCount++)
8 .withDisposed!(() => disposedCount++);
9
10 sub.put(1);
11 disposable.dispose();
12
13 assert(putCount == 1);
14 assert(disposedCount == 1);
1 import rx;
2
3 auto sub = new SubjectObject!int;
4 size_t putCount = 0;
5
6 bool disposed = false;
7 alias traceDispose = withDisposed!(() => disposed = true);
8
9 auto disposable = traceDispose(sub.doSubscribe!(_ => putCount++));
10
11 sub.put(1);
12 sub.completed();
13
14 assert(putCount == 1);
15 assert(!disposed);
1 import rx;
2
3 auto sub = new SubjectObject!int;
4 size_t putCount = 0;
5
6 bool disposed = false;
7 alias traceDispose = withDisposed!(() => disposed = true);
8
9 auto disposable = traceDispose(sub.doSubscribe!(_ => putCount++));
10
11 sub.put(1);
12 disposable.dispose();
13
14 assert(putCount == 1);
15 assert(disposed);
1 import rx;
2
3 auto sub = new SubjectObject!int;
4 size_t putCount = 0;
5
6 bool disposed = false;
7 auto disposable = sub.doSubscribe!(_ => putCount++).withDisposed(() {
8 disposed = true;
9 });
10
11 sub.put(1);
12 disposable.dispose();
13
14 assert(putCount == 1);
15 assert(disposed);
1 import rx;
2
3 auto sub = new SubjectObject!int;
4 size_t disposedCount = 0;
5
6 auto disposable = sub.doSubscribe!((int) { })
7 .withDisposed!(() { disposedCount++; });
8
9 disposable.dispose();
10 disposable.dispose();
11
12 assert(disposedCount == 1);
1 import rx;
2
3 auto sub = new SubjectObject!int;
4 size_t putCount = 0;
5
6 bool disposed = false;
7 auto disposable = sub.doSubscribe!(_ => putCount++).withDisposed(() {
8 disposed = true;
9 });
10
11 sub.put(1);
12 disposable.dispose();
13
14 assert(putCount == 1);
15 assert(disposed);
1 import rx;
2
3 auto sub = new SubjectObject!int;
4 size_t disposedCount = 0;
5
6 auto disposable = sub.doSubscribe!((int) { }).withDisposed(() {
7 disposedCount++;
8 });
9
10 disposable.dispose();
11 disposable.dispose();
12
13 assert(disposedCount == 1);