Skip to content

Commit

Permalink
Merge pull request NervJS#15742 from kongxiaojun/main
Browse files Browse the repository at this point in the history
harmony hybrid NativeApiSyncCacheProxy支持业务使用
  • Loading branch information
qican777 authored May 16, 2024
2 parents 0f4b344 + d195421 commit 1a52590
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { NativeApi } from './NativeApi'

export class NativeDataCache {
private cache = new Map<string, any>()

Expand Down Expand Up @@ -51,12 +49,12 @@ export interface NativeDataChangeListener {
* 同步数据缓存ProxyHandler
*/
export class SyncCacheProxyHandler {
private readonly nativeApi: NativeApi
private readonly nativeApi: any
private readonly listener: NativeDataChangeListener
private readonly cache: NativeDataCache
private enableMethodNames: Set<string> = new Set<string>()

constructor (nativeApi: NativeApi) {
constructor (nativeApi: any) {
this.nativeApi = nativeApi
this.cache = new NativeDataCache()
// 绑定类的this到self变量
Expand Down Expand Up @@ -113,7 +111,7 @@ export class SyncCacheProxyHandler {
return `${methodName}_${JSON.stringify(methodArgs)}`
}

get (target: NativeApi, propKey: string | symbol, receiver: any) {
get (target: any, propKey: string | symbol, receiver: any) {
const origMethod = Reflect.get(target, propKey, receiver)
const methodName = `${String(propKey)}`
if (typeof origMethod === 'function' && this.enableMethodNames.has(methodName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export * from './open-api'
export * from './payment'
export * from './qq'
// export * from './route'
export * from './NativeApiSyncCacheProxy'
export * from './share'
export * from './storage'
export * from './swan'
Expand Down

0 comments on commit 1a52590

Please sign in to comment.