I have a custFactory service with a method called createCustomer that 
creates a customer model.  This method uses data fetched from the server to 
initialize the customer model.  I would like for the createCustomer method 
to be synchronous, so as to make the method easier to work with. Of course 
the method used to fetch data is asynchronous.  I would like the method to 
look like this:

var newCust = custFactory.createCustomer();

I am aware of the resolve property used in routing, but I may want to use 
this service in a directive, in which case there is no resolve mechanism to 
ensure initialization.  

Are there any strategies for turning a method that has an asynchronous 
dependency into a synchronous method call?   Or is it just a fact of life 
that once you have introduced an async dependency into a method that that 
method needs to propagate the asynchronicity (via a promise or callback).

Sincerely,

MB

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to