File tree Expand file tree Collapse file tree 1 file changed +26
-3
lines changed
angular-ngrx-scss/src/app/file-viewer/file-explorer Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Original file line number Diff line number Diff line change 11import { Component , OnDestroy } from '@angular/core' ;
22import { Store } from '@ngrx/store' ;
33import { ActivatedRoute } from '@angular/router' ;
4- import { RepoContents , selectedRepository } from '../../state/repository' ;
5- import { map } from 'rxjs' ;
4+ import { RepoContents , fetchRepository , selectedRepository } from '../../state/repository' ;
5+ import { map , takeWhile , tap } from 'rxjs' ;
66
77@Component ( {
88 selector : 'app-file-explorer' ,
@@ -32,7 +32,30 @@ export class FileExplorerComponent implements OnDestroy {
3232 ) ;
3333 private componentActive = true ;
3434
35- constructor ( private route : ActivatedRoute , private store : Store ) { }
35+ constructor ( private route : ActivatedRoute , private store : Store ) { }
36+
37+
38+ ngOnInit ( ) {
39+ this . route . paramMap
40+ . pipe (
41+ takeWhile ( ( ) => this . componentActive ) ,
42+ tap ( ( params ) => {
43+ this . owner = params . get ( 'owner' ) as string ;
44+ this . repoName = params . get ( 'repo' ) as string ;
45+ this . branch = params . get ( 'branch' ) as string ;
46+ this . path = params . get ( 'path' ) as string ;
47+ this . store . dispatch (
48+ fetchRepository ( {
49+ owner : this . owner ,
50+ repoName : this . repoName ,
51+ path : this . path ,
52+ branch : this . branch ,
53+ } ) ,
54+ ) ;
55+ } ) ,
56+ )
57+ . subscribe ( ) ;
58+ }
3659
3760 ngOnDestroy ( ) : void {
3861 this . componentActive = false ;
You can’t perform that action at this time.
0 commit comments