takeLast

Creates a observable that take only a last element of the given source.

takeLast
(
TObservable
)
(
auto ref TObservable observable
)

Examples

import rx.subject;

auto sub = new SubjectObject!int;

int putCount = 0;
int completedCount = 0;
struct TestObserver
{
    void put(int n)
    {
        putCount++;
    }

    void completed()
    {
        completedCount++;
    }
}

auto d = sub.takeLast.subscribe(TestObserver());

assert(putCount == 0);
sub.put(1);
assert(putCount == 0);
sub.put(10);
assert(putCount == 0);
sub.completed();
assert(putCount == 1);
assert(completedCount == 1);

sub.put(100);
assert(putCount == 1);
assert(completedCount == 1);

Meta