コード例 #1
0
ファイル: solution.js プロジェクト: Vrakfall/.atom
 (function () {
     var branchSubject = new _rxjs.Subject();
     _this2._solutionDisposable.add(branchSubject.distinctUntilChanged().subscribe(function () {
         return atom.commands.dispatch(atom.views.getView(atom.workspace), "omnisharp-atom:restart-server");
     }));
     _this2._solutionDisposable.add(_this2.repository.onDidChangeStatuses(function () {
         branchSubject.next(_this2.repository.branch);
     }));
 })();
コード例 #2
0
/**
 * A utility for creating an Atom-style subscription function (`onDidChangeBlah`, `observeBlah`)
 * with an associated notification mechanism. This is just a thin wrapper around an RxJS Subject. We
 * provide our own default comparer because we want to be more strict (by default) than RxJS is.
 * (For example, RxJS will consider similar objects equal.)
 */
function createObserveFunction(comparer: Comparer = strictEquals): Result {
  const value$ = new Rx.Subject();
  const distinctValue$ = value$.distinctUntilChanged(undefined, comparer);
  // Wrap each callback so that we don't leak the fact that subscribe is implemented with
  // observables (by accepting Observers as well as callbacks).
  return {
    observe: callback => new DisposableSubscription(
      distinctValue$.subscribe(value => callback(value))
    ),
    notify(getValue) {
      // Don't calculate the next value unless somebody's listening.
      if (value$.observers.length) {
        value$.next(getValue());
      }
    },
  };
}