Model observer recursion (after save)

9 views
Skip to first unread message

Mark Johnson

unread,
Jul 21, 2016, 2:44:17 AM7/21/16
to loopb...@googlegroups.com
I have a case where after saving I want to do another process resulting in another update.  Having this in an Model.afterRemote trigger isn't really ideal as this can be updated from several sources.  Now the problem with 'after save' is I seem to get a recursive loop happening and can't seem to stop it.  That is 'after save' triggers after each update so it's stuck indefinitely in 'after save'!

Update: Also have tried updating ctx.hookState but this just seems to keep resetting itself to {}

Update 2: To date I've only been able to get around this by copying the same code to multiple afterRemote calls, and knowing there'll be a couple more to add in the future.  Whilst it's good to also refactor the code to a function called from these multiple endpoints, it seems a hacky way of getting around not being able to have a single 'after save' event and disabling the recursion on it.
Reply all
Reply to author
Forward
0 new messages