I'm curious if there are any alternatives to fetching meta data from breeze when using Angular. Since $q and Q promises don't play nice with each other I decided to only use Q.js promises and not $q. In my controller I'm checking if the metaDataStore is empty:
if (mainDataService.manager.metadataStore.isEmpty())
{
$log.info('metadataStore is empty') ;
mainDataService.getMetaData()
.then(function ()
{
EnableCreateButton();
});
}
The basic idea if I don't have meta data is to go fetch it and then enable the buttons that will allow me to create a new record.
To accomplish this I define a Q Promise in my data service then after breeze resolves the promise I resolve my promise.
function getMetaData()
{
var myMetaDataPromise = Q.defer();
Q.delay(0).then(function () {
manager.metadataStore.fetchMetadata(serviceName).then(function () {
myMetaDataPromise.resolve();
});
});
return myMetaDataPromise.promise;
}
Any suggestions to make this cleaner would be great. One thought I had was to define the promise in the controller and have the data service just return the breeze promise. I just thought that would clutter the controller up and not separate out the concerns.