Design Help

53 views
Skip to first unread message

Michael Bielski

unread,
Sep 18, 2012, 12:44:53 PM9/18/12
to ang...@googlegroups.com
I'm trying to design (what to me is) a complex function and I need to know if I am doing things correctly before I go any further. What I've got is here:  http://jsfiddle.net/mbielski/MjbhU/

The way things should work is that a new customer is created, and then:
     if the address is not blank
          add it to the customer with another HTTP Post
     if the phone number is not blank
          add it to the customer with another HTTP Post
     if the email address is not blank
          add it to the customer with another HTTP Post
     Once all HTTP posts are done
          Make another HTTP Post
     Exit Function

Each of the three sub-items require that adding a customer be completed successfully, but none of them depend upon the others to do what they need to do. Lastly, I need to wait until any and all of the inner HTTP posts are complete before moving on. I don't think what I have constructed will function the way I need it to, but I don't know  how it needs to be changed. Any help would be greatly appreciated.

James Wright

unread,
Sep 18, 2012, 1:54:57 PM9/18/12
to ang...@googlegroups.com
Is there a reason you can't just build these values up and then save it off at the end? Why all the http traffic?

Jamey

Michael Bielski

unread,
Sep 18, 2012, 2:06:11 PM9/18/12
to ang...@googlegroups.com
God how I wish you could convince the other developers I work with to do that! This should all be parsed on the back end!

My job is to duplicate a desktop application in a website, and unfortunately the way the application is set up, everything is a separate request to a different webservice. They have the luxury of harnessing the desktop processing power, and the web interface is the last thing they think about.

wieslaw

unread,
Sep 18, 2012, 2:39:40 PM9/18/12
to ang...@googlegroups.com
Anyway you can still gather all the data, validate it on client side, an then run all the services. Validation on the client side is cheap and will save some unnecessary traffic. 
Convincing your friends it out of our scope :) 

Michael Bielski

unread,
Sep 18, 2012, 2:54:58 PM9/18/12
to ang...@googlegroups.com
Sure wish I could.

So, beyond the discussion of how the traffic can/should be reduced, is the logic structure I've posted going to do what I want/need?

Peter Bacon Darwin

unread,
Sep 18, 2012, 3:47:18 PM9/18/12
to ang...@googlegroups.com
I would take a look at $q.all. This would let you run the secondary HTTP posts in parallel and then wait for them all to be successful.

On 18 September 2012 19:54, Michael Bielski <michael...@yahoo.com> wrote:
Sure wish I could.

So, beyond the discussion of how the traffic can/should be reduced, is the logic structure I've posted going to do what I want/need?

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.
 
 

Michael Bielski

unread,
Sep 19, 2012, 1:14:10 PM9/19/12
to ang...@googlegroups.com
I wasn't able to get $q.all() to work quickly, and because of time constraints I have to move on from that effort. What I did get to work is now the base for the original fiddle. It may not be the "best practice" way to do it (and if somebody wants to re-hash that fiddle to reflect those practices I'm more than receptive to ideas) but it does work and I can move on with my project. Thanks to all that tried to help.
Reply all
Reply to author
Forward
0 new messages