Hi, I'm having trouble understanding / implementing some signalling in
my application... hoping someone can help.
Working under the case of three base objects that link together, I want
to have events signalled such that if certain objects are editted,
they'll raise an event to have the connected objects update. Here's
some example objects:
ObjectA = function(uid){
this.uid = uid;
this.ObjectBList = [];
this.ObjectCList = [];
this.UpdateObjectCList = function(){
this.ObjectCList = /*grab data from master array of ObjectCs*/
}
this.UpdateObjectBList = function(){
this.ObjectBList = /*grab data from master array of ObjectBs*/
this.UpdateObjectCList();
}
}
ObjectB = function(a_uid,c_uid){
this.ObjectA_uid = a_uid;
this.ObjectC_uid = c_uid;
}
ObjectC = function(uid){
this.uid = uid;
}
If it helps, imagine these as a system of orders in a merchandise
company... the ObjectAs are orders from customers, the ObjectCs are
items I sell, and the ObjectBs are a linking object to list what items
are being sold in which orders (an order can request multiple items,
and an item can appear on multiple orders)...
Now, since there are MANY orders and items, it would demand a lot of
processing if I had to recalculate what items are in each order every
time I change some other piece of order information and the display
function is called. So I'd like to maintain those arrays
(ObjectBList[] & ObjectCList[]) and only update them if the items are
modified (say I change the cost on an item), or if the ObjectB array is
updated (I add or remove an item from an order)
I've read the documentation, but a lot of the myfunc.apply() stuff
honestly has me rather lost, so I'm wondering, what would be the best
way to add a custom signal to the functions that update the master B &
C arrays to signal the pretinent A objects to update their lists?
Like I said, I don't know the real syntax, but ideally I'd have
something like this:
in the ObjectA declaration: connect two events; "updateB" and "updateC"
When an ObjectB is added/removed: signal "updateB" on the ObjectA the
new/removed ObjectB linked to
When an ObjectC is modified: signal "updateC" on every ObjectA it's
linked to... (the list could easily be populated through filtering the
B list on c_uid, and returning all a_uid values)
Any help would be appreciated
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---