-
-
Notifications
You must be signed in to change notification settings - Fork 41
Refactor event #31
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
Refactor event #31
Conversation
lib/puppeteer/events.rb
Outdated
|
||
refine Hash do | ||
def define_const_into(target_module) | ||
self.each do |key, value| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop] reported by reviewdog 🐶
Style/RedundantSelf: Redundant self detected.
lib/puppeteer/events.rb
Outdated
target_module.const_set(key, value) | ||
target_module.define_singleton_method(key) { value } | ||
end | ||
keyset = Set.new(self.keys) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop] reported by reviewdog 🐶
Style/RedundantSelf: Redundant self detected.
lib/puppeteer/events.rb
Outdated
target_module.define_singleton_method(key) { value } | ||
end | ||
keyset = Set.new(self.keys) | ||
valueset = Set.new(self.values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop] reported by reviewdog 🐶
Style/RedundantSelf: Redundant self detected.
lib/puppeteer/events.rb
Outdated
FrameDetached: Symbol('FrameManager.FrameDetached'), | ||
LifecycleEvent: Symbol('FrameManager.LifecycleEvent'), | ||
FrameNavigatedWithinDocument: Symbol( | ||
'FrameManager.FrameNavigatedWithinDocument' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[rubocop] reported by reviewdog 🐶
Style/TrailingCommaInArguments: Put a comma after the last parameter of a multiline method call.
lib/puppeteer/events.rb
Outdated
|
||
# @see https://github.com/puppeteer/puppeteer/blob/main/src/common/Events.ts | ||
{ | ||
Page: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems Events.ts
will be removed in future.
It would be better to define these constants in PageEmittedEvents
The logic of
Page#on
in puppeteer-ruby was far different from original (JS) implementation.This PR introduces Events constants and makes the method similar to the original implementation.
Also, introduces XXXEmittedEvents, which is already introduces in puppeteer JS puppeteer/puppeteer#6179 or puppeteer/puppeteer#6174