rdkcentral / Lightning-SDK

SDK for Lightning framework
Apache License 2.0
130 stars 69 forks source link

How to correctly implement plugins #324

Closed ricardo-a-alves-alb closed 2 years ago

ricardo-a-alves-alb commented 2 years ago

Taking Profile plugin as the example, how do you attach correctly the plugin implementation?

https://github.com/rdkcentral/Lightning-SDK/blob/82b8948ca0e7efe7afe5a94ba5700d21a9cc880c/src/Launch/index.js#L45

https://github.com/rdkcentral/Lightning-SDK/blob/82b8948ca0e7efe7afe5a94ba5700d21a9cc880c/src/Profile/index.js#L32-L35

As I've seen in the above code, you can provide your implementation of the plugin interface for the getInfo/setInfo.

What is the correct approach to create the platformSettings.plugins object, since the getInfo / setInfo are functions, we can't simply create those in the settings.json file.

One of the approaches I took was something like this before the Launch is called, but seems very dirty to me:

export default function () {
  arguments[1].plugins = {
    profile: {
      getInfo: (key) => { },
      setInfo: (key, params) => {},
    },
  }
  return Launch(App, ...arguments)
}
ricardo-a-alves-alb commented 2 years ago

After some talking with @mauro1855, came to the conclusion that these wrappers are useful when you deploy your app through the Metro store. We'll think about the best approach to this, either we simulate what the Metro store does or we'll create our own wrappers.