Tool
Packhouse Tool
Property
const tool = {
install: 'function',
handler: 'function', // required
request: 'array',
response: 'string',
}Install
第一次呼叫時執行,只會執行一次。
const tool = {
install({ packhouse, store, include, utils, group }) { ... }
}Packhouse
實例化的Packhouse對象,主要在於運用Plugin。
Store
變數的容器,能在handler中被獲取。
Include
引用其他的Tool必須經過include,該接口也能引用其他Group或Line。
Group
與Group交換資料的管道,也意味著能與外部的參數進行溝通:
Utils
可以使用Packhouse提供的工具組,詳情參照Utils。
Handler
Tool被呼叫時的主執行續。
Self
主要的流程控制單元,固定在第一個參數上,以下是它的Property:
success
回傳成功結果
error
回傳錯誤結果
casting
回傳與驗證參數,詳情請參閱Mold Casting。
line
引用include的Line。
tool
引用include的Tool。
assess
驗證第一個參數是否為null或undefined,若不是則回傳第一個參數,若成立則回傳第二個參數。
assess可以接受一個Callback,當第二個參數成立時可觸發並回傳該方法的結果。
Lazy First
在Cloud Function的型態下,我們只要專注在單一功能上,意味著每次執行只要針對目的require所需的模塊即可。
Async
Install必須是同步的,但Handler允許非同步運作。
Request & Response
指定參數與回傳值的型態與驗證對象,比對方法詳情請參照Mold。
Last updated
Was this helpful?