Skip to content

Commit

Permalink
fix: afterCreate hook can return nullable values
Browse files Browse the repository at this point in the history
  • Loading branch information
bubkoo committed Dec 24, 2019
1 parent 2d705bc commit b783246
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion packages/x6/src/graph/decorator.ts
Expand Up @@ -44,7 +44,10 @@ export function afterCreate(aopName?: string | null) {
const aop = (this.options as any)[name]
if (aop != null) {
args.unshift(instance)
return util.apply(aop, this, args)
const restult = util.apply(aop, this, args)
if (restult != null) {
return restult
}
}

return instance
Expand Down
10 changes: 7 additions & 3 deletions packages/x6/src/graph/hook.ts
Expand Up @@ -370,15 +370,19 @@ export interface IHooks {
this: Graph,
newNode: Cell,
options: Cell.CreateNodeOptions,
) => Cell
) => Cell | null | undefined | void

onCreateEdge?: (
this: Graph,
newEdge: Cell,
options: Cell.CreateEdgeOptions,
) => Cell
) => Cell | null | undefined | void

onCreateGroup?: (this: Graph, newGroup: Cell, cells: Cell[]) => Cell
onCreateGroup?: (
this: Graph,
newGroup: Cell,
cells: Cell[],
) => Cell | null | undefined | void

// #endregion
}

0 comments on commit b783246

Please sign in to comment.