-
Notifications
You must be signed in to change notification settings - Fork 12
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
Implement an API for event listeners #1
Comments
I need to dig a little onto how all this works really but with only what I currently know and from what you describe I am thinking of something like Page.navigate(url="htttp://google.fr") %>%
monitor(Page.frameStoppedLoading, frameId = .res$frameId) like a condition to meet. (or However, your approach is also good. I prefer something like Page.navigate(url="htttp://google.fr") %>%
Page.frameStoppedLoading(frameId = ~ .res$frameId) where Does it make sense ? |
Events listeners are useful for two different goals:
There's a huge difference between awaiting that one event fires once and calling back a function each time the event fires.
I see a huge advantage to have R functions like |
The extra argument is really interesting. Same function for both case. I like About autocompletion, we could leverage NSE and use Otherwise, it would be a big change, but a R6 logic would help in those case Page$frameStoppedLoading$onEvent(callback = f) The whole API could be written as low level with OOP approach - don't know if it worth keeping it in mind as we loose also a lot. |
I wonder many times too for OOP: it would be much more secure but it is not clear for me how to combine R6 with promises and the websocket connexion. I see one advantage of this first draft (without OOP): we are close to the metal and how the DevTools protocol is used in Javascript. |
Yes absolutely! I think it is also easier to generate the code and the documentation using FP. Will see how it will do on the run. I'll open an issue for reference that this was a question. We'll close when we are sure. |
I think it's done. |
Implementing event listeners is not so easy.
Assume that we want to navigate on a website and ensure that the frame is loaded. Since multiple frames can be opened, we want to ensure that the main frame is loaded.
In order to achieve this task, we have to send
Page.navigate
, retrieve theframeId
of the response and register a listener on the eventPage.frameStoppedLoading
for the givenframeId
.With the current version of crrri, we have to write this (ugly) code:
So, we need to implement high level functions in order to register callbacks on events.
For instance, we could do that:
I wonder what would be the best API?
The text was updated successfully, but these errors were encountered: