use global define to touch context
This commit is contained in:
6
js-framework/src/runtime/global.ts
Normal file
6
js-framework/src/runtime/global.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Context } from "./sandbox";
|
||||
|
||||
declare global {
|
||||
const context: Context
|
||||
}
|
||||
export { }
|
@@ -77,6 +77,7 @@ export function jsCallReject(contextId: string, callbackId: string, args?: any)
|
||||
}
|
||||
|
||||
export class Context {
|
||||
holder: any
|
||||
id: string
|
||||
callbacks: Map<string, { resolve: Function, reject: Function }> = new Map
|
||||
constructor(id: string) {
|
||||
@@ -93,6 +94,9 @@ export class Context {
|
||||
})
|
||||
})
|
||||
}
|
||||
registor(instance: Object) {
|
||||
this.holder = instance
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,4 +1,14 @@
|
||||
import { View } from "./view";
|
||||
import { } from '../runtime/global'
|
||||
|
||||
export function Registor<T extends { new(...args: any[]): {} }>(constructor: T) {
|
||||
const ret = class extends constructor {
|
||||
context = context
|
||||
}
|
||||
context.registor(new ret)
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
export abstract class Page {
|
||||
onCreate(): void { }
|
||||
|
Reference in New Issue
Block a user