Is there a way to extend or inherit from a component app file in another app file?

This topic was automatically generated from Slack. You can find the original thread here.

Michelle Bergeron : For event sources, is there a way to extend or inherit from an app file in another app file? I’m creating some components for Google Sheets and need to include the Google Drive app file, but also overwrite and add some methods to it.

Dylan Sather (Pipedream) : in this case, could you use a technique like in this component? In your case:

// replace require path - just an example
const googleSheets = require("../../")

module.exports = {
  methods: {
    yourNewMethodHere() { },

Dylan Sather (Pipedream) : then you could require that app file in your component

Dylan Sather (Pipedream) : oh and sorry I see you needed to override the Google Drive app file, but you get the idea :slightly_smiling_face:

Michelle Bergeron : Awesome, thanks. How would I call the methods of the original google_drive file in the component? Using this.google_drive.name_of_method doesn’t seem to work. Also, to call those methods in the new google_drive app file, would I pass over google_drive as a parameter from the component?

Michelle Bergeron : Tried it this way as well: this[’…google_drive’].watchDrive();

Dylan Sather (Pipedream) : I’ll create an end-to-end example with an original app file, a modified app file (like you want here), and a component. Wrapping up one thing but will share in just a moment

Michelle Bergeron : Thanks

Dylan Sather (Pipedream) : GitHub - dylburger/test-app-file-override

Dylan Sather (Pipedream) : try pd dev test-component.js

Dylan Sather (Pipedream) : let me know if that all makes sense

Dylan Sather (Pipedream) : (and if that helps with your use case, or not)

Michelle Bergeron : Thanks, the example works. I’ll see if I can get it working with my components.

Michelle Bergeron : Success, woo hoo! Thanks for the help.

Dylan Sather (Pipedream) : np glad that worked