Closed mmcclimon closed 6 years ago
What would maybe make more sense is to say $context->scratchpad->for_call('setFoos')
, which would give you a hashref that's unique for that call.
I considered that, but because of the way the hook system works, a single call stack inside Ix (ix_set
) turns into potentially a bunch of different call stacks inside the client (ix_{creat,update,destroy}ed
, plus ix_postprocess_{create,update,destroy}
), so if the scratchpad just returns a nonce reference, you still need somewhere in the client to store it, and it can't just be a lexical.
(This explanation might not make any sense).
Good call...both fixed now.
+1.
We figured out a better way to do this in Topicbox, so I'm closing this now.
This came up in Topicbox, where we needed to keep track of a bunch of updates during a single transaction, then do something at the end of it.
Each top-level transaction gets a new scratchpad, which is thrown away when that transaction finishes. This could maybe be an object, and have better namespacing, but this works for now.