Coder Social home page Coder Social logo

aura.payload's People

Contributors

adamaltman avatar cxj avatar harikt avatar jakejohns avatar koriym avatar llvdl avatar pmjones avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aura.payload's Issues

Question only: $messages attribute as an array?

Did you envision the $messages attribute to be an array of messages, similar to the $output attribute, which is often treated as shown in the example below. I realize how $messages and $output are treated by user-derived classes is really up to us the users. I would however like to try to stay true to your vision to ensure that my code always plays well with the Aura and related-projects ecosystem. Thanks.

class Payload extends AuraPayload
{
    /**
     *
     * Output values carried in the payload.
     *
     * @var array
     *
     */
    protected $output = [];

    /**
     *
     * Converts the Payload to an array.
     *
     * @return array
     *
     */
    public function asArray()
    {
        $arr = [];
        foreach (get_object_vars($this) as $key => $val) {
            $arr[$key] = $val;
        }
        return $arr;
    }

    /**
     *
     * Merges added output values with the existing ones.
     *
     * @param array $output Merge these values with the existing ones.
     **
     * @return $this
     */
    public function addOutput(array $output)
    {
        $this->output = array_merge($this->output, $output);
        return $this;
    }
}

Why is the interface in a separate repo?

It's weird to me that the PayloadInterface is in a separate repository. If someone wanted to use the interface, they could do so without using the implemented class. The usability of the current interface is also questionable, since it uses a weird namespace.

I think Payload and PayloadInterface should be merged into a single repository.

Mutable?

Was there ever any discussion on mutability?

I see that equips payload is immutable, and thought I remembered some discussion around the matter, but now that I'm looking, I don't see it.

Was immutability consciously rejected for a reason?

PayloadFactory should have more creation methods.

Shouldn't the Aura\Payload\PayloadFactory have more methods; especially when creating payloads of different statuses.

E.g.

$foundPayload = $this->payloadFactory->found()->setOutput(...);

$notFoundPayload = $this->payloadFactory->notFound()->setMessages(['Resource is missing.']);

I can write the PR if you do want this functionality.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.