Closed frostmark closed 2 years ago
@bensheldon could you also take a look at this? 👀
Just to summarize what I'm seeing here.
on_assignment
and after_assignment
callbacksafter_assignment
callback. This callback is invoked after the assignment data is saved to the database (whereas the on_assignment
callback is invoked before that save takes place)Reading the original code, I want to suggest a completely different direction too:
on_assignment
(I think having either a default or additional callback sounds useful)after_assignment
callback and instead we simply move the place where on_assigment
is invoked till after it's saved in the database. Is there a functional/behavioral reason to have both callbacks? I did a little digging and didn't really see an explanation for why it should take place before save (i.e. it's not cancelable, there isn't anything subsequent that mutates the value).@bensheldon
Change the behavior such that the Experiment Callback overrides the global Configuration callback and only one is called?
Yep, it's already working that way. Default callback can be overridden in Experiment
Keep the global on_assignment (I think having either a default or additional callback sounds useful)
Don't create a separate after_assignment callback and instead we simply move the place where on_assigment is invoked till after it's saved in the database. Is there a functional/behavioral reason to have both callbacks? I did a little digging and didn't really see an explanation for why it should take place before save (i.e. it's not cancelable, there isn't anything subsequent that mutates the value).
Yep, I agree that we may don't add after_assignment
. I just didn't want to change the current behavior of on_assignment
, but I agree that there is no need to add a new type of callback and we can move on_assigment
@frostmark this looks good. Let me know when I should review.
@bensheldon this is ready for review
Released in v3.1.0
MVP for #367
on_assignment
~andafter_assignment
~after_assignment
callback and specs~Edit: final version of this PR does not include an
after_assignment
callback. Instead, theon_assignment
callback's call has been moved after the assignment is preserved in the database.