Questions about async options with the useQuery: true property

SERW2039 : do these generalities seem correct? is there something else?

Jay Vercellone : As a rule of thumb, everything related to interacting with the service API itself should go into service.app.js. This includes things like:

  • Managing tokens
  • Managing API call logic (e.g. setting the header, making the API call itself, extracting the result data, paginating the calls, etc)

For the common modules, you’ll notice that they are usually under the sources directory. They usually encapsulate logic and attributes that are common for several event sources:

  • Defining common props (e.g. the service prop in the case of service.app.js, the DB $.service.db, etc)
  • Defining common methods and hooks. For instance, the run(event) method is usually identical for several event sources, or at least it can be written to be

Jay Vercellone : Your assumptions are correct :slightly_smiling_face:

SERW2039 : Perfect, thanks :pray:

SERW2039 : so one question here, is there a recommended way to create a common variable that is shared across a component, via the service.app.js or common.js files. for instance, if i wanted common const value, say pi const pi = 3.1416 is there a way to export this? i was attempting to share the default value for timer, and put it as a the timer prop’s value:

timer: {
label: "Polling schedule",
description: "Pipedream polls Reddit for events on this schedule.",
type: "$.interface.timer",
default: {
intervalSeconds: timer_default, // by default, run every 15 minutes.
}

i tried to include this in as a direct child in the module.exports of the service.app.js file:, or as a const define in the declarations (right after the require statements importing i.e. axios). but i get an error. i guess when deploying the PD API is contacted and throws an error for it receives values that weren’s expected.

error         | component create api call responded with status: 400, body: {"error":essage\":\"timer_default not supported for prop reddit\"}"}

Jay Vercellone : For those cases I usually have methods, for example something like getTimerDelay().
The downside is that methods are only available after the component’s been initialized

SERW2039 : Interesting, I see use cases for encapsulating the value as a method. Yeah I’ve noticed props and the other exports being available after the component’s initialization.

SERW2039 : There is a commit to the PR, where I abstracted things out to the common file. I followed the example from Bitbucket where a event emitter method is handled in the common.js but it is called from the specific source file via a sort of delegate via a .bind() method. I retested the sources and all seem to work fine (a few overnight for events to be fired).

SERW2039 : I addressed comments in the github conversation, ,regarding the use of a resp[1] being returned, and a question when a pagination variable in reddit (before) is null. So that conversation remains unresolved, in case you want to review.

Jay Vercellone : OK I’ll take a look later today

Dylan Sather (Pipedream) : great, thank you Sergio, and thank you Jay for the review

Jay Vercellone : I’m taking a look at your PR but I don’t see your latest commits.
Maybe you forgot to push?

SERW2039 : Not sure what happened! But i just performed git push, lastest commits should be there. when you can, could you please confirm you see them? i know weekend is underway, so monday okay.

SERW2039 : @UR84EMEUT hey guys, any chance that you have looked at the lastest changes on the PR?

Jay Vercellone : Not yet. It’s one of my tasks for today

SERW2039 : Thank you. I see the committed changes in the PipedreamHQ/pipedream repo, within my PR (#931). Should be good :smirk:

Michelle Bergeron : I left a few comments on the Reddit PR

SERW2039 : Thank you , I’ll take a look

SERW2039 : Re Can you rename to includeSubredditDetails? So, the original name being renamed is sr_detail, but this is the name for the corresponding API parameter, I wanted to ask when it comes to the naming convention, should this rename in the methods accessing the reddit API? I.e. there’s the method async getNewHotSubredditPosts(subreddit, g, show, sr_detail, limit = 100) My thinking says that this method that hits reddit API should keep the name sr_detail as in the API docs, but when it comes to the prop definition, and its use along the different sources file should be rename. What’s your take here?

Michelle Bergeron : The instructions I’ve been given in the past are to name all variables using camelCase. Based on that, srDetail or includeSubredditDetails would be preferable to sr_detail regardless of what the variable is named in the API.