-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps(workbench): update @scion/microfrontend-platform to version 1.0.…
…0-rc.11 BREAKING CHANGE: Updating @scion/microfrontend-platform to version 1.0.0-rc.11 introduced a breaking change. More information on how to migrate can be found in the [changelog](https://github.com/SchweizerischeBundesbahnen/scion-microfrontend-platform/blob/master/docs/site/changelog/changelog.md) of the SCION Microfrontend Platform. *For Angular applications, we strongly recommend replacing zone-specific decorators for `MessageClient` and `IntentClient` with an `ObservableDecorator`. Otherwise, you may experience performance degradation due to frequent change detection cycles.* To migrate: - Remove decorators for `MessageClient` and `IntentClient`, including their registration in the bean manager (e.g., `NgZoneMessageClientDecorator` and `NgZoneIntentClientDecorator`). - Provide a `NgZoneObservableDecorator` and register it in the bean manager before starting the platform. Note to register it as a bean, not as a decorator. #### Example of an `ObservableDecorator` for Angular ```ts export class NgZoneObservableDecorator implements ObservableDecorator { constructor(private zone: NgZone) { } public decorate$<T>(source$: Observable<T>): Observable<T> { return new Observable<T>(observer => { const insideAngular = NgZone.isInAngularZone(); const subscription = source$ .pipe( subscribeInside(fn => this.zone.runOutsideAngular(fn)), observeInside(fn => insideAngular ? this.zone.run(fn) : this.zone.runOutsideAngular(fn)), ) .subscribe(observer); return () => subscription.unsubscribe(); }); } } ``` #### Example of Registering an `ObservableDecorator` in Angular ```ts const zone: NgZone = ...; // Register decorator Beans.register(ObservableDecorator, {useValue: new NgZoneObservableDecorator(zone)}); // Connect to the host zone.runOutsideAngular(() => WorkbenchClient.connect(...)); ```
- Loading branch information
1 parent
f784a28
commit 34fec1d
Showing
14 changed files
with
99 additions
and
217 deletions.
There are no files selected for viewing
90 changes: 0 additions & 90 deletions
90
apps/workbench-client-testing-app/src/app/workbench-client/ng-zone-decorators.ts
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
apps/workbench-client-testing-app/src/app/workbench-client/ng-zone-observable-decorator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2018-2022 Swiss Federal Railways | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
import {Observable} from 'rxjs'; | ||
import {NgZone} from '@angular/core'; | ||
import {observeInside, subscribeInside} from '@scion/toolkit/operators'; | ||
import {ObservableDecorator} from '@scion/microfrontend-platform'; | ||
|
||
/** | ||
* Mirrors the source, but ensures subscription and emission {@link NgZone} to be identical. | ||
*/ | ||
export class NgZoneObservableDecorator implements ObservableDecorator { | ||
|
||
constructor(private _zone: NgZone) { | ||
} | ||
|
||
public decorate$<T>(source$: Observable<T>): Observable<T> { | ||
return new Observable<T>(observer => { | ||
const insideAngular = NgZone.isInAngularZone(); | ||
const subscription = source$ | ||
.pipe( | ||
subscribeInside(fn => this._zone.runOutsideAngular(fn)), | ||
observeInside(fn => insideAngular ? this._zone.run(fn) : this._zone.runOutsideAngular(fn)), | ||
) | ||
.subscribe(observer); | ||
return () => subscription.unsubscribe(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 0 additions & 94 deletions
94
projects/scion/workbench/src/lib/microfrontend-platform/initialization/ng-zone-decorators.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.