             return bindings(state)
         }, observableFactory: { (bindings: Bindings<Event>) -> Observable<Event> in
             return Observable<Event>.merge(bindings.events)
-        }).asSignal(onErrorSignalWith: .empty())
-            .enqueue()
+        })
+            .enqueue(Signal<Event>.SharingStrategy.scheduler)
+            .asSignal(onErrorSignalWith: .empty())
+
     }
 }
 

    effects: @escaping (Control) -> Signal<Event>
) -> (Driver<State>) -> Signal<Event> {
    return { state in
        return state.map(query)
            .distinctUntilChanged { $0 != nil }
            .flatMapLatest { (control: Control?) -> Signal<Event> in
                guard let control = control else {
                    return Signal<Event>.empty()
                }

                return effects(control)
                    .enqueue()
        }
    }
}


            .share(replay: 1)

        let newQueries = Observable.zip(query, query.startWith(Set())) { $0.subtracting($1) }
        let asyncScheduler = state.scheduler.async

        return newQueries.flatMap { controls in
            return Observable<Event>.merge(controls.map { control -> Observable<Event> in
                return effects(control)
                    .enqueue(state.scheduler)
                    .takeUntilWithCompletedAsync(query.filter { !$0.contains(control) }, scheduler: asyncScheduler)
            })
        }
    }
}

extension ObservableType {
    // This is important to avoid reentrancy issues. Completed event is only used for cleanup
    fileprivate func takeUntilWithCompletedAsync<O>(_ other: Observable<O>, scheduler: ImmediateSchedulerType) -> Observable<E> {
            // this little piggy will delay completed event
            let completeAsSoonAsPossible = Observable<E>.empty().observeOn(scheduler)
            return other
                .take(1)
                .map { _ in completeAsSoonAsPossible }
                // this little piggy will ensure self is being run first
                .startWith(self.asObservable())
                // this little piggy will ensure that new events are being blocked immediatelly
                .switchLatest()
    }
}

