Hi,
Just following up on the thread that was started on this commit:
http://github.com/wilkes/karras/commit/fe67b74e69380ca6961eeac675b8da70cb41eb9d
Wilkes:
"I removed [callbaks] so that I can get 0.4.0 release out. I'm not
convinced that the callback implementation is the way I want to do it,
so I pulled it out until I made my mind up.
I would love to see some examples of how you are using the callbacks.
I think the implementation that I removed was a bit of cargo cult
baggage and that there's a more idiomatic way to deal with it. I
haven't used them much so I'm speculating. The tentative plan is to go
with something more like Django's signals. Another idea is to use
technomancy's robert-hooke or a similar approach. I'll write something
after I play around with it and post it on karras-dev to get some
feedback."
I totally agree WRT cargo culting... The funny thing is that I
generally avoid AR-like callbacks on the Ruby side of things and
prefer to use observers. I must admit that karras' original
implementation of callbacks was a little awkward to work with.
Awkward in that it wasn't open to extension (if I can borrow an OO
term...). Composing several fns for the same CB is fine, but it
seemed wrong that I always had to modify the original entity file to
add such behavior. I haven't used Django's signals before but it
sounds like we are on the same page.
Aside from the dubious and admittedly abusive use of callbacks that I
alluded to in my other thread about references we do have legitimate
use cases for callbacks. The prime candidate being for reporting.
After a record is created we send it to a function that updates
several counts in other collections (so that reports are quick reads
as opposed to map-reduce operations). This is really the only real
use case I think we have and we typically only need it for after-
create (although I could see needing something similar for after-
update). In this case we don't "modify" the original entity at all
and so the thread-through aspect of the current CBs wasn't really
needed in this case.
Hope that helps and let me know if you have any other questions,
Ben