vendredi 23 octobre 2015

Ember Utility class for accessing data across different places

I am new to Ember and want a Utility class in Ember which does the following, takes in rowItems and returns an object (finalMeta)

var myMeta1 = new Array();
var myMeta2 = new Array();

dojo.forEach(rowItems, dojo.hitch(this, function(rowItem){

    var metaData = {
            Id: rowItem.Id,
            version: rowItem.version
    };

    if(rowItem.tranMetaData.template){
        myMeta2.push(metaData);
    }else{
        myMeta1.push(metaData);
    }
}));

if(myMeta1.length == 0){
    myMeta1 = null;
}

if(myMeta2.length == 0){
    myMeta2 =  null;
}

var finalMeta = {
    "myMeta1": myMeta1,
    "myMeta2": myMeta2
};

return finalMeta;

Where/How do I write this Utility class, such that it can be accessed from a different place (say from a different route) ?

Just to add, I want to use the finalMeta in a child route (part of some workflow) as inputs/request params to some API.




Aucun commentaire:

Enregistrer un commentaire