Closed kelunik closed 8 years ago
It can be discussed whether LoopDriverFactory
should be an interface or a simple callable
, but I think it's fine having an interface.
This looks great. Libraries can set their own factories as the default, but users can always override if they wish.
I think using a simple callable is really good enough here; especially when an user wants to use his own factory, it ends up being more usable.
Can we merge it or should I change it to be a simple callable
if we anyway can't use return types?
I'd try and avoid discussion on anything more than implementation details on a PR.
If there's a significant design choice to be had, we should open an issue, summarise any arguments made so far and then start a discussion.
@AndrewCarterUK That's an implementation detail.
Okay, I personally prefer the interface to a callable because it's more explicit (I am a factory that does this).
However, if other people disagree I'd prefer we discuss in an issue until we reach consensus.
@bwoebi Could you please open an issue if you want to change it to a callable or respond that we can merge it?
@kelunik opened #42 to discuss this.
Should we go with make
or create
?
CreateDriver is fine.
You mean I should rename it from create
to createDriver
?
Oh, in factory. I thought you were talking about the static function on loop.
Nah, there just create
is fine.
I just applied the changes required for the registry (we also need a default one) and added the running bool, to reset loop / factory if a new factory is set and no loop is running.
I think this should be ready to merge then.
Looks good to me now ... I'd like to merge it soon, in case nobody objects until tomorrow.
LGTM. Let's rename it to Interop\Async\Loop\DriverFactory
once #40 is merged.
The LoopDriverFactory SHOULD be used by driver implementations to set a default event loop driver.
This can be achieved by having a Composer autoloader like that:
Where
src/bootstrap.php
contains the following code:This ensures the user doesn't have to care about setting the actual driver. A user just has to require the specific event loop driver package he / she wants to use.