Skip to content

Parameter order for delay and repeat #54

@joshdifabio

Description

@joshdifabio

I noticed that for both delay() and repeat() the callback param comes before the time/interval param. This is the same as Amp's reactor interface but different to Icicle and React's event loop interfaces which both place the time/interval param first. The current approach results in code like the following:

$reactor->delay(function () {
    //lots
    //of
    //code
    //here
    //...
    //...
}, 1000);

versus the alternative

$reactor->delay(1000, function () {
    //lots
    //of
    //code
    //here
    //...
    //...
});

The latter seems much easier to grok, which I noticed when re-factoring some code from React\EventLoop today. Has this been discussed or are people pretty happy with the Amp ordering of params?

Note that onReadable, onWritable and onSignal all require the stream/signal nr. params before the callbacks in the current interface, so it's not like the callback is always placed first for consistency reasons.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions