This repository was archived by the owner on Oct 1, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
src/app/operators/components/operator Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export const OPERATOR_TOKEN = new InjectionToken<string>('operators');
2020} )
2121export class OperatorComponent implements OnInit {
2222 public operator : OperatorDoc ;
23+ public operatorsMap : { string ?: OperatorDoc } ;
2324
2425 private readonly baseSourceUrl = 'https://github.com/ReactiveX/rxjs/blob/master/src/operators/' ;
2526 private readonly baseSpecUrl = 'http://reactivex.io/rxjs/test-file/spec-js/operators' ;
@@ -32,13 +33,23 @@ export class OperatorComponent implements OnInit {
3233 ) { }
3334
3435 ngOnInit ( ) {
36+ this . operatorsMap = this . operators . reduce (
37+ ( acc : { string ?: OperatorDoc } , value : OperatorDoc ) => {
38+ acc [ value . name ] = value ;
39+ return acc ;
40+ } ,
41+ { }
42+ ) ;
43+
3544 this . _activatedRoute . params
3645 . pipe ( pluck ( 'operator' ) )
3746 . subscribe ( ( name : string ) => {
38- this . operator =
39- this . operators . filter (
40- ( operator : OperatorDoc ) => operator . name === name
41- ) [ 0 ] || this . notfound ( ) ;
47+ if ( name in this . operatorsMap ) {
48+ this . operator = this . operatorsMap [ name ] ;
49+ } else {
50+ this . notfound ( ) ;
51+ return ;
52+ }
4253 this . _seo . setHeaders ( {
4354 title : [ this . operator . name , this . operator . operatorType ] ,
4455 description : this . operator . shortDescription
You can’t perform that action at this time.
0 commit comments