apex-enterprise-patterns / fflib-apex-common

Common Apex Library supporting Apex Enterprise Patterns and much more!
BSD 3-Clause "New" or "Revised" License
914 stars 517 forks source link

How does the trigger pattern handle downstream trigger events? #42

Closed scottmcclung closed 9 years ago

scottmcclung commented 9 years ago

After reading Andrew's book and blog articles I'm ready to dive in, but still trying to wrap my head around everything.
Up until now, I've been following the trigger pattern that Dan Appleman talks about in his Advanced Apex Programming book. A feature of his pattern is the ability to control how downstream trigger events, caused by DML in the initial trigger, are handled. (Advanced Apex Programming pgs 126-132) As I plan to update my code to use enterprise patterns, I'm not sure how to implement that same behavior.

Can you explain the program flow in the fflib_SObjectDomain.triggerHandler method. Specifically, what is it doing with TriggerStateByClass and how should we be using TriggerStateEnabled? How do we manage the downstream trigger events?

tmowbrey commented 9 years ago

Try reading this blog post: http://andyinthecloud.com/2014/06/28/financialforce-apex-common-updates/

You'll want to focus on the trigger state portion.

afawcett commented 9 years ago

Thanks @tmowbrey could reference i forgot about that post! :+1:

@scottmcclung Does this help?

afawcett commented 9 years ago

@scottmcclung Let me know if you need more help figure this out. :+1: