Skip to content

Commit 0717a94

Browse files
committed
replace short Type
1 parent 9995538 commit 0717a94

File tree

10 files changed

+53
-62
lines changed

10 files changed

+53
-62
lines changed

src/foundation/AbstactPanel.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module mvc {
3838
}
3939

4040

41-
addReayHandle(handle: (e: EventX) => void, thisObj?: any): boolean {
41+
addReayHandle(handle: Action<EventX>, thisObj?: any): boolean {
4242
if (this._isReady) {
4343
handle(EventX.ReadyEventX);
4444
return true;
@@ -56,7 +56,7 @@ module mvc {
5656
this.readyHandle.push(new ListenerItemBox(handle, thisObj));
5757
return true;
5858
}
59-
removeReayHandle(handle: (e: EventX) => void, thisObj?: any): boolean {
59+
removeReayHandle(handle: Action<EventX>, thisObj?: any): boolean {
6060
if (this._isReady) {
6161
return false;
6262
}

src/foundation/ListenerItemBox.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class ListenerItemBox<T>{
2-
constructor(public handle: (e: T) => void,public thisObj:any){}
2+
constructor(public handle: Action<T>,public thisObj:any){}
33
}

src/foundation/SocketX.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class SocketX {
4848
SocketX.sender.removeEventListener(type,listener,thisObj,false);
4949
}
5050

51-
public static AddListener(code: number, handler: (e: IStream) => void, thisObj: any): boolean {
51+
public static AddListener(code: number, handler: Action<IStream>, thisObj: any): boolean {
5252
let list = SocketX.cmds[code];
5353
if (!list) {
5454
list = new Array<ListenerItemBox<IStream>>();

src/mvc/Facade.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace mvc {
2424
public hasMediatorByName(mediatorName: string): boolean {
2525
return this.view.get(mediatorName) != null;
2626
}
27-
public hasMediator<T extends IMediator>(c: new () => T): boolean {
27+
public hasMediator<T extends IMediator>(c: ClassT<T>): boolean {
2828
let aliasName = Singleton.GetAliasName(c);
2929
return this.hasMediatorByName(aliasName);
3030
}
@@ -51,15 +51,15 @@ namespace mvc {
5151
this.model.register(proxy);
5252
}
5353

54-
public registerCommand<T>(eventType: string, c: new () => T): boolean {
54+
public registerCommand<T>(eventType: string, c: ClassT<T>): boolean {
5555
if (this.commandsMap[eventType]) {
5656

5757
return false;
5858
}
5959
this.commandsMap[eventType] = c;
6060
return true;
6161
}
62-
public removeCommand<T>(eventType: string, c: new () => T): boolean {
62+
public removeCommand<T>(eventType: string, c: ClassT<T>): boolean {
6363
if (this.commandsMap[eventType]) {
6464

6565
delete this.commandsMap[eventType]
@@ -87,7 +87,7 @@ namespace mvc {
8787
return this.mvcInjectLock[className];
8888
}
8989

90-
protected routerCreateInstance(type: new () => any): any {
90+
protected routerCreateInstance(type: Class): any {
9191
return new type();
9292
}
9393

@@ -99,7 +99,7 @@ namespace mvc {
9999
}
100100

101101

102-
public getMediator<T extends IMediator>(c: new () => T): T {
102+
public getMediator<T extends IMediator>(c: ClassT<T>): T {
103103
let aliasName = Singleton.GetAliasName(c);
104104
let ins = <T>this.getMediatorByName(aliasName);
105105
if (!ins) {
@@ -110,22 +110,22 @@ namespace mvc {
110110
return ins;
111111
}
112112

113-
public static GetMediator<T extends IMediator>(c: new () => T): T {
113+
public static GetMediator<T extends IMediator>(c: ClassT<T>): T {
114114
return Facade.GetInstance().getMediator(c);
115115
}
116-
public static GetProxy<T extends IProxy>(c: new () => T): T {
116+
public static GetProxy<T extends IProxy>(c: ClassT<T>): T {
117117
return Facade.GetInstance().getProxy(c);
118118
}
119119

120-
public static ToggleMediator<T extends IMediator>(c: new () => T): T {
120+
public static ToggleMediator<T extends IMediator>(c: ClassT<T>): T {
121121
return Facade.GetInstance().toggleMediator(c);
122122
}
123123

124124

125125
public hasProxyByName(proxyName: string): boolean {
126126
return this.model.get(proxyName) != null;
127127
}
128-
public hasProxy<T extends IProxy>(c: new () => T): boolean {
128+
public hasProxy<T extends IProxy>(c: ClassT<T>): boolean {
129129
let aliasName = Singleton.GetAliasName(c);
130130
return this.hasProxyByName(aliasName);
131131
}
@@ -142,7 +142,7 @@ namespace mvc {
142142
}
143143
return proxy;
144144
}
145-
public getProxy<T extends IProxy>(c: new () => T): T {
145+
public getProxy<T extends IProxy>(c: ClassT<T>): T {
146146
let aliasName = Singleton.GetAliasName(c);
147147
let ins = <T>this.getProxyByName(aliasName);
148148
if (!ins) {
@@ -212,7 +212,7 @@ namespace mvc {
212212
return mediator;
213213
}
214214

215-
public toggleMediator<T extends IMediator>(c: new () => T, type: number = -1): T {
215+
public toggleMediator<T extends IMediator>(c: ClassT<T>, type: number = -1): T {
216216
let aliasName = Singleton.GetAliasName(c);
217217
let t = <T>this.toggleMediatorByName(aliasName, type);
218218
if (t == null) {

src/mvc/core/AbstractMVHost.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module mvc {
4545
this.readyHandle.push(new ListenerItemBox(handle, thisObj));
4646
return true;
4747
}
48-
public removeReayHandle(handle: (e: EventX) => void, thisObj?: any): boolean {
48+
public removeReayHandle(handle: Action<EventX>, thisObj?: any): boolean {
4949
if (this._isReady) {
5050
return false;
5151
}

src/mvc/core/Attribute.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ function MVCE(type: InjectEventType, ...events: Array<string>) {
4141

4242
namespace mvc{
4343
export class InjectEventTypeHandle {
44-
public constructor(public injectType: InjectEventType, public events: Array<string>, public handle: (EventX) => void) { }
44+
public constructor(public injectType: InjectEventType, public events: Array<string>, public handle: Action<EventX>) { }
4545
}
4646
export class InjectClassData {
4747
public propertys: { [index: string]: any } = {};
4848
//指令
49-
public cmds: { [index: number]: Array<(e: IStream) => void> } = {};
49+
public cmds: { [index: number]: Array<Action<IStream>> } = {};
5050
public constructor(public classPrototype: Function) {
5151
}
5252
/**
@@ -81,7 +81,7 @@ namespace mvc{
8181
}
8282
classInjectData.propertys[property] = 1;
8383
}
84-
public static AddCMD(classPrototype: Function, cmd: number, handle: (e: IStream) => void) {
84+
public static AddCMD(classPrototype: Function, cmd: number, handle: Action<IStream>) {
8585
let classInjectData = null;
8686
for (let item of InjectAttribute.injectMapping) {
8787
if (item.classPrototype == classPrototype) {
@@ -96,7 +96,7 @@ namespace mvc{
9696

9797
let list = classInjectData.cmds[cmd];
9898
if (!list) {
99-
list = new Array<(e: IStream) => void>();
99+
list = new Array<Action<IStream>>();
100100
classInjectData.cmds[cmd] = list;
101101
}
102102
if (list.indexOf(handle) == -1) {

src/mvc/core/MVCInject.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module mvc {
3737
this.facade = facade;
3838
}
3939

40-
private getInjectClassByDef(classInjectData: InjectClassData, property: string): new () => any {
40+
private getInjectClassByDef(classInjectData: InjectClassData, property: string): Class {
4141
let fullClassName = classInjectData.getFullClassName();
4242
let dic = MVCInject.injectDefMapping[fullClassName];
4343
if (!dic) {
@@ -105,7 +105,7 @@ module mvc {
105105
}
106106

107107
}
108-
protected autoMVC(classType: new () => any): any {
108+
protected autoMVC(classType:Class): any {
109109
let fullClassName = Singleton.GetClassFullName(classType);
110110
if (Singleton.IsUnique(fullClassName)) {
111111
return Singleton.GetInstance(fullClassName);

src/mvc/core/Singleton.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ namespace mvc {
33
/**
44
* 单例辅助
55
*/
6-
private static uniqueClassMap: { [index: string]: new () => any } = {};
6+
private static uniqueClassMap: { [index: string]: Class } = {};
77
private static uniqueInstanceMap: { [index: string]: any } = {};
88

99
/**
1010
* 类名或都别名找到类
1111
*/
12-
private static __classMap: { [index: string]: new () => any } = {};
12+
private static __classMap: { [index: string]: Class } = {};
1313

1414
/**
1515
* 别名关系表
@@ -21,7 +21,7 @@ namespace mvc {
2121
* 取得一个别名,或者短名称 (eg: com.lingyu.BagView 得到已注册的别名 或者生成一个规则下的短名:BagView )
2222
* @param fullClassName 完整的类名
2323
*/
24-
static GetAliasName(fullClassName: string | { new(): any }): string {
24+
static GetAliasName(fullClassName: string | Class): string {
2525
if (fullClassName) {
2626
let str: string;
2727
if (typeof fullClassName == "string") {
@@ -58,7 +58,7 @@ namespace mvc {
5858
* @param aliasName 取一个别名
5959
* @param fullClassName 实际的完整类名(因为js默认编译是不包含包的名称空间或者模块,完整名称有利于区别不同的模块下面的同名类)
6060
*/
61-
public static RegisterUnique<T>(c: new () => T, aliasName?: string, fullClassName?: string) {
61+
public static RegisterUnique<T>(c: ClassT<T>, aliasName?: string, fullClassName?: string) {
6262
if (!fullClassName) {
6363
fullClassName = Singleton.GetClassFullName(c);
6464
}
@@ -81,7 +81,7 @@ namespace mvc {
8181
* 注册类的别名(批量)
8282
* @param arg
8383
*/
84-
public static RegisterMulitClass(...arg: Array<new () => any>) {
84+
public static RegisterMulitClass(...arg: Array<Class>) {
8585
for (const iterator of arg) {
8686
if (iterator) Singleton.RegisterClass(iterator);
8787
}
@@ -93,7 +93,7 @@ namespace mvc {
9393
* @param aliasName 取一个别名
9494
* @param fullClassName 实际的完整类名(因为js默认编译是不包含包的名称空间或者模块,完整名称有利于区别不同的模块下面的同名类)
9595
*/
96-
public static RegisterClass<T>(c: new () => T, aliasName?: string, fullClassName?: string) {
96+
public static RegisterClass<T>(c: Class, aliasName?: string, fullClassName?: string) {
9797
if (!fullClassName) {
9898
fullClassName = Singleton.GetClassFullName(c);
9999
}
@@ -185,7 +185,7 @@ namespace mvc {
185185
* 用别名 取得一个类型
186186
* @param aliasName 别名/完整类名
187187
*/
188-
public static GetClass(aliasName: string): new () => any {
188+
public static GetClass(aliasName: string): Class {
189189
if (!aliasName) {
190190
console.error("aliasName is empty:" + aliasName);
191191
return null;

src/mvc/interface/IFacade.ts

+18-27
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,53 @@
11
namespace mvc {
22
export interface IFacade extends INotifier {
3-
4-
/**
5-
/**
6-
* h5特有的注册类 操作(因为js代码的 初始化顺序关系,可能会有互相依赖项,不能直接由反射来操作,所以注册了关系用于直接初始化)
7-
* @param mediatorClass
8-
* @param proxyClass
9-
* @param viewClass
10-
*/
11-
//registerModule<M extends IMediator,P extends IProxy,V extends IPanel>(mediatorClass:new()=>M,proxyClass:new()=>P,viewClass:new()=>V):boolean;
123

134
/**
145
*
156
* @param name 视图管理类
167
*/
17-
getMediatorByName(name:string):IMediator;
18-
getMediator<T extends IMediator>(c: new () => T): T;
8+
getMediatorByName(name: string): IMediator;
9+
getMediator<T extends IMediator>(c: ClassT<T>): T;
1910

20-
hasMediatorByName(mediatorName:string):boolean;
21-
hasMediator<T extends IMediator>(c: new () => T):boolean
11+
hasMediatorByName(mediatorName: string): boolean;
12+
hasMediator<T extends IMediator>(c: ClassT<T>): boolean
2213

23-
toggleMediatorByName(mediatorName:string, type?:number):IMediator;
24-
toggleMediator<T extends IMediator>(c: new () => T,type?:number):T;
25-
registerMediator(mediator:IMediator);
14+
toggleMediatorByName(mediatorName: string, type?: number): IMediator;
15+
toggleMediator<T extends IMediator>(c: ClassT<T>, type?: number): T;
16+
registerMediator(mediator: IMediator);
2617

2718
/**
2819
*
2920
* @param proxyName 数据管理类
3021
*/
31-
getProxyByName(proxyName:string):IProxy;
32-
getProxy<T extends IProxy>(c: new () => T):T;
22+
getProxyByName(proxyName: string): IProxy;
23+
getProxy<T extends IProxy>(c: ClassT<T>): T;
3324

34-
hasProxyByName(proxyName:string):boolean;
35-
hasProxy<T extends IProxy>(c: new () => T):boolean;
36-
registerProxy(proxy:IProxy);
25+
hasProxyByName(proxyName: string): boolean;
26+
hasProxy<T extends IProxy>(c: ClassT<T>): boolean;
27+
registerProxy(proxy: IProxy);
3728

3829
/**
3930
*
4031
* @param eventType 注册事件
4132
* @param c 事件独立处理类
4233
*/
43-
registerCommand<T>( eventType:string, c:new()=>T):boolean
44-
removeCommand<T>( eventType:string, c:new()=>T):boolean
45-
hasCommand(eventType:string):boolean;
46-
34+
registerCommand<T>(eventType: string, c: ClassT<T>): boolean
35+
removeCommand<T>(eventType: string, c: ClassT<T>): boolean
36+
hasCommand(eventType: string): boolean;
37+
4738
/**
4839
*
4940
* @param eventInterester 关注事件处理类
5041
* @param injectEventType 关注类型
5142
* @param isBind 添加还是删除
5243
*/
53-
registerEventInterester(eventInterester:IEventInterester,injectEventType:InjectEventType, isBind?:boolean);
44+
registerEventInterester(eventInterester: IEventInterester, injectEventType: InjectEventType, isBind?: boolean);
5445

5546
/**
5647
* 用于限制互相依赖的锁
5748
* @param className
5849
*/
59-
getInjectLock(className:string):any;
50+
getInjectLock(className: string): any;
6051
__unSafeInjectInstance(toLockInstance: IMVCHost, className?: string)
6152
}
6253
}

src/mvc/interface/Interface.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ namespace mvc {
44
* @property index:InjectEventType;
55
*/
66
__eventInteresting: { [index: string]: Array<InjectEventTypeHandle> };
7-
getEventInterests(type: InjectEventType): Array<InjectEventTypeHandle>;
7+
getEventInterests(InjectEventType): Array<InjectEventTypeHandle>;
88
}
99
export interface IView {
10-
get(name: string): IMVCHost;
11-
register(host: IMVCHost): boolean;
12-
remove(host: IMVCHost): boolean;
10+
get(string): IMVCHost;
11+
register(IMVCHost): boolean;
12+
remove(IMVCHost): boolean;
1313
}
1414
export interface IMVCHost extends IAsync, IEventInterester, IInjectable {
1515
readonly name: string;
@@ -19,13 +19,13 @@ namespace mvc {
1919
export interface IAsync {
2020
readonly isReady: boolean;
2121
startSync(): boolean;
22-
addReayHandle(handle: (e: EventX) => void): boolean;
22+
addReayHandle(handle: Action<EventX>): boolean;
2323
}
2424
export interface INotifier {
2525
simpleDispatch(type: string, data: any): boolean
2626
}
2727
export interface ICommand {
28-
execute(e: EventX): void;
28+
execute(EventX): void;
2929
}
3030
export interface IInject {
3131
inject(target: IInjectable): IInjectable;

0 commit comments

Comments
 (0)