Created
July 7, 2021 08:12
-
-
Save Purecaesar/adb1e146829ba83fd4a7f803968c149b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
... | |
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