-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: version * feat: add material hook (#1024) * feat: add material hook * feat: 增加log * feat: 升级版本,补充changelog * feat: 补充log * feat: 修改文件名 * feat: 修改方法名 Co-authored-by: qiansheng.wjz <[email protected]> * fix: lint Co-authored-by: wjz <[email protected]> Co-authored-by: qiansheng.wjz <[email protected]>
- Loading branch information
1 parent
87c8566
commit 93464d3
Showing
13 changed files
with
198 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# CHANGELOG | ||
|
||
## 0.2.2 | ||
|
||
- feat: add hook utils | ||
|
||
## 0.2.1 | ||
|
||
- feat: support get component type | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* hook utils | ||
*/ | ||
const hookStore = {}; | ||
|
||
export interface IMaterialHookHandler { | ||
(action: string, data?: any, args?: any): any; | ||
} | ||
|
||
export function registerHook(action: string, handler: IMaterialHookHandler) { | ||
if (!action || !handler) { | ||
return; | ||
} | ||
|
||
hookStore[action] = hookStore[action] || []; | ||
|
||
console.log('registerHook', action); | ||
|
||
hookStore[action].push(handler); | ||
} | ||
|
||
export function trigger(action: string, ...data: any) { | ||
if (!action || !hookStore[action]) { | ||
console.log(`triggerHook, no action or no handler. action: ${action}`); | ||
return; | ||
} | ||
|
||
console.log('triggerHook', action); | ||
|
||
const handlers = hookStore[action]; | ||
|
||
handlers.forEach((handler) => { | ||
if (handler && typeof handler === 'function') { | ||
handler(...data); | ||
} | ||
}); | ||
} |
Oops, something went wrong.