Implements Observers
Observers allow for custom callbacks to be defined at critical locations in the DataMapper core, which could be used to pre- or post process the object's data, add additional logic, etc.
Original issue from DataMapper v1.
see http://codeigniter.com/forums/viewthread/149388/P530/#783616 and http://codeigniter.com/forums/viewthread/149388/P540/#783667
Observers should replace the static code now built-in for working with created and updated timestamps in records. This means less code and quicker execution for those that don't need this feature.
Reply from @colonelchorine
Wan, I noticed that Jamierumbelow's base model MY_Model uses various callbacks/hooks for before and after events. I've always found this kind of confusing, because I find that by simply using standard OOP inheritance, you can accomplish the same thing.
Like so:
class Something extends BaseModel {
function update() {
do_something_before();
parent::update();
do_something_after();
}
}
Not sure if this fits into the Datamapper pattern you've made, but it was just a thought.
This works for real "before" and "after", but not for hook points in the code, like "before_save", "before_insert", etc.