-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…1533) * feat(ng-lib): use GuardsCheckEnd instead of Navigationend. see #1529 ISSUES CLOSED: #1529 * fix(monorepo): add workaround for [#22606](angular/angular-cli#22606) ISSUES CLOSED: #1529 * test(ng-lib): add test to check if tss works with route-resolvers ISSUES CLOSED: #1529
- Loading branch information
1 parent
2b222f3
commit dc27565
Showing
16 changed files
with
207 additions
and
73 deletions.
There are no files selected for viewing
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
Empty file.
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
20 changes: 20 additions & 0 deletions
20
apps/sample-blog/src/app/tss-resolver/tss-resolver-routing.module.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,20 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule, Routes } from '@angular/router'; | ||
import { TssResolverComponent } from './tss-resolver.component'; | ||
import { UserResolver } from './user.resolver'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: TssResolverComponent, | ||
resolve: { | ||
user: UserResolver, | ||
}, | ||
}, | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule], | ||
}) | ||
export class TssResolverRoutingModule {} |
Empty file.
19 changes: 19 additions & 0 deletions
19
apps/sample-blog/src/app/tss-resolver/tss-resolver.component.html
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,19 @@ | ||
<section *ngIf="user$ | async as user; else loading"> | ||
<h4>User Data</h4> | ||
|
||
<section id="user"> | ||
<label>Id</label> | ||
<p>{{ user.id }}</p> | ||
<label>Name</label> | ||
<p>{{ user.name }}</p> | ||
<label>email</label> | ||
<p>{{ user.email }}</p> | ||
<label>company</label> | ||
<p>{{ user.company.name }}</p> | ||
</section> | ||
|
||
<strong>{{ user.company.catchPhrase }}</strong> | ||
</section> | ||
<ng-template #loading> | ||
<section>Loading ...</section> | ||
</ng-template> |
24 changes: 24 additions & 0 deletions
24
apps/sample-blog/src/app/tss-resolver/tss-resolver.component.spec.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,24 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { TssResolverComponent } from './tss-resolver.component'; | ||
|
||
describe('TssResolverComponent', () => { | ||
let component: TssResolverComponent; | ||
let fixture: ComponentFixture<TssResolverComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [TssResolverComponent], | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(TssResolverComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
apps/sample-blog/src/app/tss-resolver/tss-resolver.component.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,16 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { pluck, tap } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'scullyio-tss-resolver', | ||
templateUrl: './tss-resolver.component.html', | ||
styleUrls: ['./tss-resolver.component.css'], | ||
}) | ||
export class TssResolverComponent implements OnInit { | ||
user$ = this.route.data.pipe(pluck('user')); | ||
|
||
constructor(private route: ActivatedRoute) {} | ||
|
||
ngOnInit(): void {} | ||
} |
11 changes: 11 additions & 0 deletions
11
apps/sample-blog/src/app/tss-resolver/tss-resolver.module.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,11 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
import { TssResolverRoutingModule } from './tss-resolver-routing.module'; | ||
import { TssResolverComponent } from './tss-resolver.component'; | ||
|
||
@NgModule({ | ||
declarations: [TssResolverComponent], | ||
imports: [CommonModule, TssResolverRoutingModule], | ||
}) | ||
export class TssResolverModule {} |
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,15 @@ | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Injectable } from '@angular/core'; | ||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router'; | ||
import { TransferStateService } from '@scullyio/ng-lib'; | ||
import { User } from '@sentry/node'; | ||
import { first, Observable } from 'rxjs'; | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class UserResolver implements Resolve<User> { | ||
constructor(private http: HttpClient, private tss: TransferStateService) {} | ||
|
||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<User> { | ||
return this.tss.useScullyTransferState('tssUsers', this.http.get<User>('http://localhost:8200/users/10')).pipe(first()); | ||
} | ||
} |
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
Oops, something went wrong.