Skip to content

Instantly share code, notes, and snippets.

@Purecaesar
Created July 7, 2021 08:12
Show Gist options
  • Save Purecaesar/adb1e146829ba83fd4a7f803968c149b to your computer and use it in GitHub Desktop.
Save Purecaesar/adb1e146829ba83fd4a7f803968c149b to your computer and use it in GitHub Desktop.
...
triger
.pipe(
switchMap(() => {
const currentActivatedOutlet = getCurrentOutlet(
rootContextMap,
target.constructor
);
if (!currentActivatedOutlet)
throw new Error('Component is not in router tree');
const outlet: any = currentActivatedOutlet.outlet;
const routeWithData = getRouteWithData(
currentActivatedOutlet.route,
name || key,
propagation
);
compRef = outlet.activated as ComponentRef<any>;
cdr = compRef.injector.get(ChangeDetectorRef);
compRef.onDestroy(() => {
inited = false;
destroyer.next();
});
return routeWithData.data.pipe(
pluck(name || key),
takeUntil(destroyer)
);
})
)
.subscribe({
next: data => {
target[key] = data;
cdr.markForCheck();
}
});
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment