Skip to content

Commit

Permalink
fix(core/reactShims): Fix the state.go wrapper such that it correctly…
Browse files Browse the repository at this point in the history
… exposes the `transition`

(it's been inconsequentially broken a long time and nobody noticed)
  • Loading branch information
christopherthielen committed Jul 15, 2019
1 parent ac2f61c commit 39a27e6
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions app/scripts/modules/core/src/reactShims/react.injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,21 @@ export class CoreReactInject extends ReactInject {
const $rootScope = this.$injector.get('$rootScope') as IRootScopeService;
const $q = this.$injector.get('$q') as IQService;
const originalGo = wrappedState.go;

// Calls $state.go() inside the angularjs digest
// I forget exactly what this does, but it fixes some angularjs-y digest cycle problem we had once
wrappedState.go = function () {
const args = arguments;
const deferred = $q.defer();
const promise = Object.create(deferred);
promise.promise.transition = null;
promise.promise.catch(() => {});
const deferred = Object.create($q.defer());
const { promise } = deferred;
promise.transition = null;
promise.catch(() => {});
$rootScope.$applyAsync(() => {
promise.transition = originalGo.apply(this, args).then(promise.resolve, promise.reject);
const originalPromise = originalGo.apply(this, args);
promise.transition = originalPromise.transition;
originalPromise.then(deferred.resolve, deferred.reject);
});
return promise.promise;
return promise;
};
return wrappedState;
}
Expand Down

0 comments on commit 39a27e6

Please sign in to comment.