mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
add callbacksInvoker missing api (#12131)
This commit is contained in:
@@ -31,6 +31,7 @@ import { createMap } from '../utils/js-typed';
|
||||
import { property } from '../data/class-decorator';
|
||||
import { getUrlWithUuid } from '../asset-manager/helper';
|
||||
import { extname } from '../utils/path';
|
||||
import { ExtraEventMethods } from '../utils/jsb-utils'
|
||||
import '../data/object';
|
||||
|
||||
declare const jsb: any;
|
||||
@@ -41,7 +42,7 @@ declare const jsb: any;
|
||||
*/
|
||||
export type CreateNodeCallback = (error: Error | null, node: Node) => void;
|
||||
|
||||
applyMixins(jsb.Asset, [CallbacksInvoker]);
|
||||
applyMixins(jsb.Asset, [CallbacksInvoker, ExtraEventMethods]);
|
||||
|
||||
const assetProto: any = jsb.Asset.prototype;
|
||||
|
||||
|
||||
@@ -158,3 +158,13 @@ export function updateChildrenForDeserialize (node: Node) {
|
||||
// });
|
||||
// node._isChildrenRedefined = true;
|
||||
// }
|
||||
type EventType = string | number;
|
||||
export function ExtraEventMethods () {}
|
||||
|
||||
ExtraEventMethods.prototype.once = function once <Callback extends (...any) => void> (type: EventType, callback: Callback, target?: any) {
|
||||
return this.on(type, callback, target, true) as Callback;
|
||||
};
|
||||
|
||||
ExtraEventMethods.prototype.targetOff = function targetOff (typeOrTarget: any) {
|
||||
this.removeAll(typeOrTarget);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user