您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

RPCConfigLoader.ts 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { ConfigLoader } from 'loadson'
  2. import { RPCExporter } from 'rpclibrary'
  3. export type ConfigLoaderIfc<ConfT> = {
  4. Config : {
  5. getConfig: () => ConfT
  6. resetConfig: () => ConfT
  7. setConfig: (conf:ConfT) => ConfT
  8. setConfigKey: (key:string, value:any) => ConfT
  9. deleteConfigKey: (key:string) => ConfT
  10. getConfigKey: (key:string) => any
  11. }
  12. }
  13. export class RPCConfigLoader<ConfT>
  14. extends ConfigLoader<ConfT>
  15. implements RPCExporter<ConfigLoaderIfc<ConfT>, "Config">{
  16. name = "Config" as "Config"
  17. exportRPCs() {
  18. return [{
  19. name: "getConfig" as "getConfig",
  20. call: () => { return this.getConfig() }
  21. },{
  22. name: "resetConfig" as "resetConfig",
  23. call: () => { return this.resetConfig() }
  24. },{
  25. name: "setConfig" as "setConfig",
  26. call: (conf:ConfT) => { return this.setConfig(conf) }
  27. },{
  28. name: "setConfigKey" as "setConfigKey",
  29. call: (key:string, value:any) => { return this.setConfigKey(key, value) }
  30. },{
  31. name: "deleteConfigKey" as "deleteConfigKey",
  32. call: (key:string) => { return this.deleteConfigKey(key) }
  33. },{
  34. name: "getConfigKey" as "getConfigKey",
  35. call: (key:string) => { return this.getConfigKey(key) }
  36. }]
  37. }
  38. }