Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sync BotAction's #41

Open
mrWh1te opened this issue Aug 15, 2020 · 1 comment
Open

Support sync BotAction's #41

mrWh1te opened this issue Aug 15, 2020 · 1 comment
Labels
architecture npm Packaging, Releases, Dist related proposal New feature or change

Comments

@mrWh1te
Copy link
Owner

mrWh1te commented Aug 15, 2020

Concerned about how most of Puppeteer's Page's methods are async so some dev's may try to await or resolve promises inside sync functions but page.url() is sync, and other BotActions would run faster if ran synchronously such as map() in a Pipe, etc

Concept/Idea
Same method parameters (page: Page, ...injects: any[]), but instead of returning a Promise, it either doesn't return (void) or returns a PipeValue. Therefore, all assembly lines need to check the returned value for something scalar like undefined or a PipeValue, and test it for being a Promise. If a promise, then await it before proceeding further.

As per interfaces, idea is:

interface BotAction<R = void, I extends Array<any> = any[]> extends Function {
  (page: Page, ...injects: I) : Promise<R> | R
}
@mrWh1te mrWh1te added the proposal New feature or change label Aug 18, 2020
@mrWh1te mrWh1te changed the title Proposition: Support sync BotAction's Support sync BotAction's Aug 18, 2020
@mrWh1te
Copy link
Owner Author

mrWh1te commented Aug 18, 2020

This would effect a new minor release ie 2.1.0

@mrWh1te mrWh1te added the npm Packaging, Releases, Dist related label Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architecture npm Packaging, Releases, Dist related proposal New feature or change
Projects
None yet
Development

No branches or pull requests

1 participant