public function singleInstance(): Observable
    {
        $hasObservable = false;
        $observable = null;
        $source = $this;

        $getObservable = function () use (&$hasObservable, &$observable, $source): Observable {
            if (!$hasObservable) {
                $hasObservable = true;
                $observable = $source
                    ->finally(function () use (&$hasObservable) {
                        $hasObservable = false;
                    })
                    ->publish()
                    ->refCount();
            }
            return $observable;
        };

        return new Observable\AnonymousObservable(function (ObserverInterface $o) use ($getObservable) {
            return $getObservable()->subscribe($o);
        });
    }