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

[10.x] Add Conditionable trait to Sleep class #47100

Closed
wants to merge 1 commit into from
Closed

[10.x] Add Conditionable trait to Sleep class #47100

wants to merge 1 commit into from

Conversation

bradietilley
Copy link
Contributor

From #47092

This PR adds the Conditionable trait to the Sleep class. Example:

Sleep::for(1)->second()
    ->unless(
        $some->status === SomeStatus::PENDING,
        fn (Sleep $sleep) => $sleep->and(500)->milliseconds()
    );

@nunomaduro
Copy link
Member

Personally feel that it's very unlikely that people would want todo something like this. However, on the other hand, it would be cool "cancel" the pause doing something like:

Sleep::for(1)->second()->unless($task->completed());

As usual, let's wait to see what Taylor thinks.

@nunomaduro nunomaduro changed the title Add Conditionable trait to Sleep class [10.x] Add Conditionable trait to Sleep class May 15, 2023
@bradietilley
Copy link
Contributor Author

I like that syntax.

Sleep::for(1)->second()->unless($task->completed());
// or
Sleep::for(1)->second()->when($task->pending());

I can move https://github.com/bradietilley/framework/pull/1/files into this PR if the above syntax is preferred.

@taylorotwell
Copy link
Member

Yeah personally like the syntax suggested by Nuno a bit better.

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.

3 participants