Support Callback Data in javascript OpenSRF requests

Bug #939535 reported by Jason Stephenson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenSRF
New
Undecided
Unassigned

Bug Description

I'm working on something in the Evergreen staff client that would be much easier to implement if the OpenSRF javascript request framework supported callback data for response and completion callbacks. The additional data will allow the callbacks to communicate state with each other.

Revision history for this message
Jason Stephenson (jstephenson) wrote :

Code at working/user/dyrcona/lp939535 on evergreen-ils.org/working/OpenSRF.git.

This feels like it was too easy.

Revision history for this message
Bill Erickson (berick) wrote :

I think previously this kind of thing was handled by tacking ad-hoc fields onto the request object. E.g. req._mystuff = foo; I like the idea of formalizing it, though. One comment on the code... I could be wrong, I haven't tested this, but wouldn't it be enough to capture the callbackdata in the OpenSRF.Request constructor (like you have), but without passing it around to the other layers? Inside the caller's oncomplete() handler, they can acces the callback data like => oncomplete : function(req) { var cbd = req.callbackdata; ... }

Revision history for this message
Jason Stephenson (jstephenson) wrote :

Bill,

I'm so used to doing callbacks in C and similar languages that I used the approach required there.

After coding the above, I did realize that I probably could have just made the variables visible at certain levels and then access it from the call backs. I do, however, prefer the formality of the C-style callback data.

If you think the code should be changed a bit, then that's fine. I'll just need to alter my code that uses it.

Revision history for this message
Dan Scott (denials) wrote :

Jason, Bill - have you guys come to a conclusion on this? I'd like to know whether I should roll this branch into 2.1.0 RC2.

Revision history for this message
Bill Erickson (berick) wrote :

Sorry for holding things up, Dan. I have no objections to Jason's code.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.