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

Add ReusableRelay #9

Merged
merged 4 commits into from
Jun 25, 2015
Merged

Add ReusableRelay #9

merged 4 commits into from
Jun 25, 2015

Conversation

pmjones
Copy link
Contributor

@pmjones pmjones commented Jun 24, 2015

This is an interim PR to add the ReusableRelay functionality without disturbing the previous single-use Relay functionality.

The steps after this would be to:

  1. Rename Relay to Runner,
  2. Rename RelayFactory to RunnerFactory,
  3. Rename ReusableRelay to Relay,
  4. Remove the existing RelayBuilder, and
  5. Rename ReusableRelayBuilder to RelayBuilder.

The renames have the effect of making a Relay reusable by default, and the Runner the single-use dispatcher that the Relay uses.

@pmjones
Copy link
Contributor Author

pmjones commented Jun 24, 2015

@shadowhand This is the next iteration of the "reusable" PR separation.

namespace Relay;

class RelayFactory
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to have @var declarations for the $queue and $resolver.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@pmjones
Copy link
Contributor Author

pmjones commented Jun 24, 2015

Note that this is an interim PR, intended to split the earlier bigger PR into digestible chunks. As long as the functionality is clear, renaming and docblocks can be part of the final renaming PR.

|| $queue instanceof ArrayObject;

if ($getArrayCopy) {
return $queue->getArrayCopy();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be more useful to use iterator_to_array instead of array copying? The code could look like this:

protected function getArray($queue)
{
    if (is_array($queue)) {
        return $queue;
    }
    return iterator_to_array($queue);
}

This way you can bypass the instanceof checks entirely and rely on builtins.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah so! I like that idea, though it does not apply specifically to the reusability of the relay; that logic pre-exists in the 1.x branch in RelayBuilder. Let's take a look at that separately from this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@pmjones
Copy link
Contributor Author

pmjones commented Jun 25, 2015

@shadowhand I think that last push addresses your notes here. Further thoughts?

@shadowhand
Copy link
Contributor

Looks good to me.

@pmjones
Copy link
Contributor Author

pmjones commented Jun 25, 2015

Sweet.

pmjones pushed a commit that referenced this pull request Jun 25, 2015
@pmjones pmjones merged commit 6f1f1e2 into 1.x Jun 25, 2015
@pmjones pmjones deleted the add-reusable branch June 25, 2015 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants