Idea: Make ElementPoller a trait and make `ElementQuery` and `ElementWaiter` generic over `T: ElementPoller`
stevepryde opened this issue · 2 comments
Currently the ElementQuery
and ElementWaiter
allow the use of different ElementPoller
s where ElementPoller
is an enum. It stores the default poller as configuration inside thirtyfour
and allows the poller to be specified explicitly if a different one is needed.
I realised that we can avoid the dependency on this configuration storage by simply baking the poller in as a generic type. My thinking on this is "why do we need to store the default configuration if we can just specify the poller explicitly via a type?". This allows users to create their own polling mechanisms if desired, and also removes the need for internal configuration storage. This in turn allows ElementQuery
and ElementWaiter
to be implemented not just for thirtyfour
but also directly for fantoccini
as well.
As for how to make use of a particular poller by default, I think for now this means creating a type alias for ElementQuery<MyPoller>
and constructing that directly to do queries rather than using something like client.query(...)
. I need to think about this aspect more, because this part isn't as ergonomic as I'd like just yet.
This in turn allows ElementQuery and ElementWaiter to be implemented not just for thirtyfour but also directly for fantoccini as well.
Actually ignore this part. This may be possible at some future time if thirtyfour
can reduce down to just additional trait impls over fantoccini
types. I'm not sure if that will be possible eventually but it's something to keep in mind.
As for how to make use of a particular poller by default
I am leaning towards making ElementPoller::TimeoutWithInterval
the only option and removing the other options. If people want other polling options they can implement their own by implementing the required traits.
This will be included in v0.30.0