iOS:add ListItem actions api

This commit is contained in:
pengfei.zhou
2021-04-23 19:05:33 +08:00
committed by osborn
parent cc7df5d2ca
commit e18b7e781e
18 changed files with 167 additions and 36 deletions

View File

@@ -1,7 +1,7 @@
export interface Modeling {
toModel(): Model;
}
export declare function obj2Model(obj: Model): Model;
export declare function obj2Model(obj: Model, convertor: (v: Function) => string): Model;
declare type _M = string | number | boolean | Modeling | {
[index: string]: Model;
} | undefined;

View File

@@ -1,6 +1,9 @@
export function obj2Model(obj) {
if (obj instanceof Array) {
return obj.map(e => obj2Model(e));
export function obj2Model(obj, convertor) {
if (obj instanceof Function) {
return convertor(obj);
}
else if (obj instanceof Array) {
return obj.map(e => obj2Model(e, convertor));
}
else if (obj instanceof Object) {
if (Reflect.has(obj, 'toModel') && Reflect.get(obj, 'toModel') instanceof Function) {
@@ -10,7 +13,7 @@ export function obj2Model(obj) {
else {
for (let key in obj) {
const val = Reflect.get(obj, key);
Reflect.set(obj, key, obj2Model(val));
Reflect.set(obj, key, obj2Model(val, convertor));
}
return obj;
}