IIRC ->data was added when we were trying to make it easier for people to 
fix circular references in nonblocking code, I only used it a few times. It 
can almost always be replaced by making a my $data = {}; before creating 
the delay and then using $data->{...} rather than $delay->data->{...}. 
Should almost be as easy to replace/fix as ->catch. BTW most of my catch 
uses were easily fixed because they just were use to bubble out exceptions. 
Nearly always is was ->catch(sub{ $self->$cb($_[1], ...) }) (where the $cb 
has an error as its second slot and possibly other args) you can replace it 
with ->catch(sub{ $self->$cb(pop, ...) }). which doesn't break like $_[1] 
did.

Remaining was added I think (as sri hinted) to make things like 
partitioning/limiting and condvar-like usages easier but indeed I don't 
think I ever used them in that way either. Every time I almost used it I 
could think of a better way with some other pattern.

Overall I agree with sri that the change to add Promises/A+ to delays will 
make them more composable and help make non-blocking code easier to reason 
about, especially for people coming from Javascript. I'm sorry that you 
have some breakage along the way but hopefully it will be worth it in the 
end.

Joel


On Friday, November 10, 2017 at 6:35:22 AM UTC-6, sri wrote:
>
> When retrieving the starting point data from a back end it sometimes 
>> includes references to other objects. 
>> We keep most of the response data around in the "data" attribute of the 
>> delay and start harvesting the referenced data, which we need to have 
>> around before continuing to the original second step.
>> For this we prepend new steps like this:
>>
>> $delay->steps( @new, @{$delay->remaining} );
>>
>> The final step can be quite generic, taking everything it needs out of 
>> the $delay->data, processing it as required and passing it back to the main 
>> application.
>>
>
> If you want to keep doing that you're welcome to fork the old 
> Mojo::IOLoop::Delay and release it to CPAN
> with a new name. Although i believe anything that can't be solved with 
> ->begin/pass/steps should be done
> with promises in the future. Our implementation is very similar to 
> JavaScript promises, so there is a lot of
> examples on the internet already that can be adapted with little effort.
>
>
> When implementing M:I:Delay::data and M:I:Delay::remaining something like 
>> this must have been the intended use case.
>>
>
> Honestly, i don't really remember why exactly ->data and ->remaining were 
> added. They were a rather
> shortsighted workaround for limitations of the overall design pattern and 
> i don't remember ever using
> them myself.
>
>
> --
> sebastian
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to