Factory

FactoryPackhouse最高群組單位,是Group的容器,也是最基本的對外接口。

Packhouse.createFactory({
    bridge: function() {}
})

Options

Bridge

  • function
  • optional

當從factory呼叫group時,會先觸發bridge行為。

let factory = Packhouse.createFactory({
    // Bridge可以用在動態加載Group
    bridge(factory, groupName, toolName) {
        if (factory.hasGroup(groupName) === false) {
            factory.addGroup(groupName, require(`../groups/${groupName}`))
        }
    }
})

Group

factory.addGroup('groupName', group)

移除Group

factory.removeGroup('groupName')

呼叫Tool

factory.tool('groupName', 'toolName').action(...)

呼叫Line

factory.line('groupName', 'lineName')(...).action(...)