remix-project
remix-project copied to clipboard
implement ts plugin api in core plugins
Defining plugin plugins like this will actually allow type checking on calls, events etc. We can always make an internal RemixApi definition that allows internal plugins to call methods that we don't expose to the public webclient api. This is an example how to do it in the config plugin.
const profile: Profile = {
name: 'config',
displayName: 'Config',
description: 'Config',
methods: ['getAppParameter', 'setAppParameter']
}
interface configPluginApi {
methods: {
getAppParameter(name: string): void
setAppParameter(name: string, value: any): void
},
events: StatusEvents
}
interface IInternalRemixApi extends IRemixApi {
config: configPluginApi
}
type internalRemixApi = Readonly<IInternalRemixApi>;
export class ConfigPlugin extends Plugin<configPluginApi, internalRemixApi> implements MethodApi<configPluginApi> {
constructor() {
super(profile)
}