Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

[需求]运行时插件 #983

Closed
yesmeck opened this issue May 22, 2020 · 0 comments · Fixed by #988
Closed

[需求]运行时插件 #983

yesmeck opened this issue May 22, 2020 · 0 comments · Fixed by #988
Labels

Comments

@yesmeck
Copy link
Member

yesmeck commented May 22, 2020

需求描述

现在碰到一些场景,应用需要去修改 App 或者 Page 的小程序定义。比如一些监控的 SDK:

import Track from 'track-sdk;

App(
  Track({   
    onLaunch () {},
    onShow () {},
    onHide () {},
    onError (error) {}
  })
);

目前这样的 SDK 是没法在 Remax 应用里使用的。

解决方案

支持运行时的插件,通过插件来支持上面这样的需求。

新增 addRuntimePlugin hook:

// track.js
export default () => {
  addRuntimePlugin() => path.resolve(__dirname, './runtime.js'), // 返回值是 runtime 插件的文件路径
}
// runtime.js
import Track from 'track-sdk;

export default () => {
  onAppConfig({ config }) => {
    return Track({   
      onLaunch () {},
      onShow () {},
      onHide () {},
      onError (error) {}
    })
  }
}
yesmeck added a commit that referenced this issue May 22, 2020
yesmeck added a commit that referenced this issue May 22, 2020
yesmeck added a commit that referenced this issue May 22, 2020
yesmeck added a commit that referenced this issue May 23, 2020
yesmeck added a commit that referenced this issue May 26, 2020
* feat: 支持运行时插件

close #983

* fix: fix runtime plugin path
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant