Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: disposing unit should not emit error #2529

Merged
merged 13 commits into from
Jun 15, 2024
Prev Previous commit
Next Next commit
fix: fix disposing sequence
  • Loading branch information
wzhudev authored and ybzky committed Jun 15, 2024
commit dc6b0a9fffe280d503369ca7813775c00a91b029
7 changes: 5 additions & 2 deletions packages/core/src/services/instance/instance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class UniverInstanceService extends Disposable implements IUniverInstance
}

private _unitDisposed$ = new Subject<UnitModel>();
unitDisposed$ = this._unitDisposed$.asObservable();
readonly unitDisposed$ = this._unitDisposed$.asObservable();
getTypeOfUnitDisposed$<T extends UnitModel<object, number>>(type: UniverInstanceType): Observable<T> {
return this.unitDisposed$.pipe(filter((unit) => unit.type === type)) as Observable<T>;
}
Expand Down Expand Up @@ -242,10 +242,13 @@ export class UniverInstanceService extends Disposable implements IUniverInstance
const index = units.indexOf(unit);
units.splice(index, 1);

this._unitDisposed$.next(unit);
// Firstly un-mark the unit as "current".
this._currentUnits$.next({ ...this._currentUnits$.getValue(), [type]: null });
this._focused$.next(null);

// Then dispose the unit.
this._unitDisposed$.next(unit);

return true;
}

Expand Down