0.0.7 • Published 8 years ago
p6-service v0.0.7
p6-service
Hooks - The heart of our system
Types
before-global- Run before all servicebefore-service- Run before a service, detect by SIDafter-service- Run after a service, , detect by SIDafter-global- Run after all service
How to result of service will be solve?
- Run
before-global->beforeGlobalResult.ServiceResultisbeforeGlobalResult - Run
before-servicewith latest params isServiceResult->beforeServiceResult.ServiceResultisObject.assign({}, ServiceResult, beforeServiceResult) - Run
after-servicewith latest params isServiceResult->afterServiceResult.ServiceResultisObject.assign({}, ServiceResult, afterServiceResult) - Run
after-globalwith ONE params isServiceResult->afterGlobalResult.ServiceResultisObject.assign({}, ServiceResult, afterGlobalResult) - Return
ServiceResult
Break the chain
You cann break the chain of hook by using flag __break on your return result.
before-global-> break after run ALLbefore-globalhooksbefore-service-> break after run ALLbefore-globalandbefore-servicehookshandler-> break after run ALLbefore-global,before-servicehooks an your mainhandlerafter-service-> break after run ALLbefore-global,before-servicehooks, your mainhandlerandafter-serviceafter-globalAs default mode, your service will run through your handler and all hooks