I've started putting together a way to specify per-object before/after
callbacks for any method. Probably not something to go in core, but
maybe something that would be interesting to core contributors.

There are some examples in a GitHub wiki (http://github.com/nakajima/
nakatype/wikis/callbacks), but basically, you specify callbacks like

  var someArray = [1,2,3];

  Callbacks.add(someArray, {
    before: {
      push: function(entry) {
        var msg = 'about to push ' + entry + ' on array: ' +
this.join(', ');

    after: {
      push: function(entry) {
        var msg = 'just pushed ' + entry + ' on array: ' +
this.join(', ');


In addition to adding 4 to someArray, the above code snippet will log
to the console before and after.

If anybody has any suggestions/criticisms/threats, please do share!
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to