Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
156 lines (78 sloc) 5.26 KB

BXObject

Location: bloxley.base.BXObject

BXObject is the superclass for all significant Bloxley classes. It contains methods for message passing, method cascading, and reflection.

Should you subclass this? Yes, any time you create a new class that you want to have access to bloxley's features

Should you instantiate this? No, this class doesn't do anything on its own.

ID Methods

id():int

Every instance of BXObject gets a unique id number. This method returns that number.

Should you override this? No, most classes depend on it working the way it does.

Should you call this? Yes, any time you want an easy way to recognize a unique BXObject.

Mailbox Methods

listenFor(message:String, source:BXObject, fcn)

When the object source posts a message message to the mailbox, call fcn on this object. fcn can be a fcntion object, or the string name of a method that the caller responds to.

Should you override this? No, most classes depend on it working the way it does.

Should you call this? Yes, any time you want to observe a particular message.

listenForAny(message:String, fcn)

When any object posts a message message to the mailbox, call 'fcn' on this object. fcn can be a fcntion object, or the string name of a method that the caller responds to.

Should you override this? No, most classes depend on it working the way it does.

Should you call this? Yes, any time you want to observe a particular message.

post(message:String, info = null)

Post a message to the mailbox, optionally with some additional information

Should you override this? No, most classes depend on it working the way it does.

Should you call this? Yes, when you want to post a message.

postLater(message:String, seconds:Number, info = null)

In seconds seconds, post the message message to the mailbox, optionally with some additional information.

Should you override this? No, most classes depend on it working the way it does.

Should you call this? Yes, when you want to post a message at some point in the future.

later(fcn, info:Object = null)

Later this frame, call the provided method. fcn can be a fcntion object, or the string name of a method that the caller responds to.

Should you override this? No, most classes depend on it working the way it does.

Should you call this? Yes, when you want a method to be called, but after the current call chain resolves.

stopListening(...rest)

Remove this object from the mailbox, preventing it from receiving any more messages

Should you override this? No, most classes depend on it working the way it does.

Should you call this? Yes, when you're ready for this object to be garbage collected.

recordListeningFor(message)

Record that this object is listening for a particular message

Should you override this? No, most classes depend on it working the way it does.

Should you call this? No, bloxley calls this method internally.

messagesListeningFor():Array

What messages are this object listening for?

Should you override this? No, most classes depend on it working the way it does.

Should you call this? No, bloxley calls this method internally.

recordListenedTo(message)

Record that some object is listening for a particular message from this object.

Should you override this? No, most classes depend on it working the way it does.

Should you call this? No, bloxley calls this method internally.

messagesListenedTo():Array

What messages are objects waiting for from this object?

Should you override this? No, most classes depend on it working the way it does.

Should you call this? No, bloxley calls this method internally.

Cascading Methods

callCascade(meths:Array, args:Array = null)

Given a list of methods (provided as strings), it will find the first that this object responds to, and call it on this object, returning the result.

Should you override this? No, most classes depend on it working the way it does.

Should you call this? Maybe? bloxley uses it internally but it can be useful in particular circumstances.

callResolve(meth:String, objects:Array, args:Array = null)

Given a method and an array of objects, it will call the method named meth on the first object that responds to it, returning the results.

Should you override this? No, most classes depend on it working the way it does.

Should you call this? Maybe? bloxley uses it internally but it can be useful in particular circumstances.

Reflection Methods

respondsTo(method:String):Boolean

Does this object have a method named method?

Should you override this? No, most classes depend on it working the way it does.

Should you call this? Sure.

className():String

What is the name of this class?

Should you override this? No, most classes depend on it working the way it does.

Should you call this? Sure.

klass():Class

What is the class object that this is an instance of?

Should you override this? No, most classes depend on it working the way it does.

Should you call this? Sure.

Utility Methods

toString():String

Return a string description of this object.

Should you override this? Yes, every class should define this however it wants.

Should you call this? Sure, for testing and debugging purposes.

You can’t perform that action at this time.