feat(preloader): preloader service which can take a list of promises and execute smth once all promises are completed

This commit is contained in:
nixa 2016-05-24 16:40:17 +03:00
parent 02fdd09bc0
commit d1f368e571
6 changed files with 63 additions and 4 deletions

View file

@ -1,5 +1,7 @@
import {Component, ViewChild, ViewEncapsulation, Input, Output, ElementRef, EventEmitter} from '@angular/core';
import {BaThemePreloader} from '../../../theme/services';
import './baAmChart.loader.ts';
import {BaAmChartThemeService} from './baAmChartTheme.service';
@ -18,6 +20,7 @@ export class BaAmChart {
@ViewChild('baAmChart') private _selector:ElementRef;
constructor (private _baAmChartThemeService:BaAmChartThemeService) {
this._loadChartsLib();
}
ngOnInit() {
@ -28,4 +31,12 @@ export class BaAmChart {
let chart = AmCharts.makeChart(this._selector.nativeElement, this.baAmChartConfiguration);
this.onChartReady.emit(chart);
}
private _loadChartsLib():void {
BaThemePreloader.registerLoader(new Promise((resolve, reject) => {
AmCharts.ready(function(){
resolve('AmCharts ready');
});
}));
}
}