88bd76eb6e10b6588ffd04e127e658ce1b759cef
[ccsdk/cds.git] /
1 import {Component, OnDestroy, OnInit} from '@angular/core';
2 import {DesignerStore} from '../designer.store';
3 import {PackageCreationStore} from '../../package-creation/package-creation.store';
4 import {Subject} from 'rxjs';
5 import {distinctUntilChanged, takeUntil} from 'rxjs/operators';
6 import {CBAPackage} from '../../package-creation/mapping-models/CBAPacakge.model';
7
8 @Component({
9     selector: 'app-functions-attribute',
10     templateUrl: './functions-attribute.component.html',
11     styleUrls: ['./functions-attribute.component.css']
12 })
13 export class FunctionsAttributeComponent implements OnInit, OnDestroy {
14
15     ngUnsubscribe = new Subject();
16     private designerDashboardState: DecodeSuccessCallback;
17     private cbaPackage: CBAPackage;
18
19     constructor(private designerStore: DesignerStore,
20                 private packageCreationStore: PackageCreationStore) {
21     }
22
23     ngOnInit() {
24         this.designerStore.state$
25             .pipe(
26                 distinctUntilChanged((a: any, b: any) => JSON.stringify(a) === JSON.stringify(b)),
27                 takeUntil(this.ngUnsubscribe))
28             .subscribe(designerDashboardState => {
29                 this.designerDashboardState = designerDashboardState;
30             });
31
32         this.packageCreationStore.state$
33             .pipe(
34                 distinctUntilChanged((a: any, b: any) => JSON.stringify(a) === JSON.stringify(b)),
35                 takeUntil(this.ngUnsubscribe))
36             .subscribe(cbaPackage => {
37                 this.cbaPackage = cbaPackage;
38             });
39
40     }
41
42     ngOnDestroy() {
43         this.ngUnsubscribe.next();
44         this.ngUnsubscribe.complete();
45     }
46 }