1

I am trying to learn Angular + Breeze (Using HotTowel.Angular and HotTowel.Angular.Breeze).

My current problem resolves around trying to hook up Breeze directly to a WCF Data Services (OData) connection (not using a BreezeController).

It seems to hook up and is calling for metadata. But since breeze.MetadataStore().FetchMetadata returns a promise, I can't wait for it to be done.

So my app keeps plowing right along. And it gets to a look up before the metadata is back and parsed.

Is there someway to tell Breeze to run fetchMetadata synchronously?
If not, then how does everyone else deal with the metadata/data race?

Vaccano
  • 78,325
  • 149
  • 468
  • 850
  • Note, Breeze will get the metadata automatically. See this answer to see what the real problem was for me: http://stackoverflow.com/a/23371102/16241 – Vaccano Apr 29 '14 at 17:14

1 Answers1

0

Just use a Q.js promise. Breeze depends on Q.js and all of the queries return a promise. Handle the then event by loading up your stuff after metadata is finished.

manager.fetchMetadata().then(function () { console.log('Finished, do something else'); });
PW Kad
  • 14,953
  • 7
  • 49
  • 82
  • Problem is that the first query is run on the activate method of my view. I need my view's `activate` to wait till the metadata call is done. – Vaccano Apr 28 '14 at 22:08
  • I don't know how to tell angular not to activate the first view until the then call is done. – Vaccano Apr 28 '14 at 22:14
  • 1
    http://stackoverflow.com/questions/11972026/delaying-angularjs-route-change-until-model-loaded-to-prevent-flicker – PW Kad Apr 28 '14 at 22:34