Skip to content

Instantly share code, notes, and snippets.

@Purecaesar
Created July 5, 2021 09:56
Show Gist options
  • Save Purecaesar/2c1ef15344d29a0c9fb62436fc3b4ba3 to your computer and use it in GitHub Desktop.
Save Purecaesar/2c1ef15344d29a0c9fb62436fc3b4ba3 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 compRef = outlet.activated as ComponentRef<any>;
const routeWithData = getRouteWithData(
currentActivatedOutlet.route,
name || key,
propagation
);
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