Hello,
I have a Chart component that could receive data to render as a Promise or as a regular JavaScript Object. It should be able to handle both cases within didInsertElement
event. How can I safely recognize that data
is a Promise or not?
{{ember-chart data=chartData}}
// components/ember-chart
import Ember from "ember";
export default Ember.Component.extend({
didInsertElement: function() {
var canvas = this.get('element');
var context = canvas.getContext('2d');
canvas.width = Ember.$(canvas).parent().width();
canvas.height = Ember.$(canvas).parent().height();
var _this = this;
//*********** if this.get('data') is not a Promise BOOM!
this.get('data').then(function(chartData){
var data = chartData;
// do other stuff before rendering
});
},
Thanks