Skip to content

Instantly share code, notes, and snippets.

View Purecaesar's full-sized avatar
🎾

Georgy Purecaesar

🎾
View GitHub Profile
...
return {
get() {
if (!inited) {
inited = true;
triger.next();
}
return originalDescriptor
? originalDescriptor.get.call(compRef.instance)
...
triger
.pipe(
switchMap(() => {
const currentActivatedOutlet = getCurrentOutlet(
rootContextMap,
target.constructor
);
if (!currentActivatedOutlet)
export function NgResolve(name?: string, propagation = true) {
return function(
target: any,
key: string,
originalDescriptor?: TypedPropertyDescriptor<any>
): any {
const router = StaticInjectorService.Injector.get(Router);
const triger = new Subject();
const destroyer = new Subject();
const rootContextMap = (router as any).rootContexts.contexts as Map<
import { ChangeDetectorRef, ComponentRef } from '@angular/core';
import { OutletContext, Router } from '@angular/router';
import { Subject } from 'rxjs';
import { pluck, switchMap, takeUntil } from 'rxjs/operators';
import { getCurrentOutlet } from '../functions/get-current-outlet';
import { getRouteWithData } from '../functions/get-route-with-data';
import { StaticInjectorService } from '../services/static-injector.service';
export function NgResolve(name?: string, propagation = true) {
return function(
...
{
path: ':id',
component: LazyComponent,
resolve: {
data: LazyResolverService
},
children: [
{
path: 'nested',
...
{
path: ':id',
component: LazyComponent,
resolve: {
data: LazyResolverService
},
children: [
{
path: 'nested',
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgResolve } from '../../ng-resolve/decorators/ng-resolve.decorator';
@Component({
selector: 'app-nested',
template: `
<div>I'm nested! And NgResolve doesn't work here :(</div>
<br />
{{ nestedData }}
`,
import { ChangeDetectorRef, ComponentRef } from '@angular/core';
import { OutletContext, Router } from '@angular/router';
import { Subject } from 'rxjs';
import { pluck, switchMap, takeUntil } from 'rxjs/operators';
import { getCurrentOutlet } from '../functions/get-current-outlet';
import { getRouteWithData } from '../functions/get-route-with-data';
import { StaticInjectorService } from '../services/static-injector.service';
export function NgResolve(name?: string, propagation = true) {
return function(
...
return {
get() {
if (!inited) {
inited = true;
triger.next();
}
return originalDescriptor
? originalDescriptor.get.call(target)
...
.subscribe({
next: data => {
target[key] = data;
cdr.markForCheck();
}
});
...