Promise...d::Mojo(3)

πŸ“¦
version 1.05 Β· 2 versions
, in fedora 43

✨ NAME ✨

Promises::Deferred::Mojo β€” an implementation of Promises in Perl πŸ’– (yes bestie, this is the Mojo-flavored one, it lives in the User Contributed Perl Documentation corner of your perldoc, and its manual page title is literally Promise...d::Mojo(3) because somebody at the terminal was being cute with truncation πŸ’…)


🌸 VERSION 🌸

version 1.05 β€” that's the vibe, that's the number, no cap.


πŸ¦‹ SYNOPSIS πŸ¦‹

use Promises backend => ['Mojo'], qw[ deferred collect ];

# ... everything else is the same

Like. That's it. That's the whole switch-up. Everything else stays exactly the same as whatever you were already doing, periodt. πŸŽ€


πŸ’œ DESCRIPTION πŸ’œ

okay so here's the tea β˜• β€” the "Promise/A+" spec is strongly suggesting (like, it really wants this, it's giving main character energy) that the callbacks you hand to then should be run asynchronously, meaning they fire off in the next turn of the event loop. This module is the one that makes that happen, and it does it using the Mojo::IOLoop module. slay. πŸ”₯

So if you're a module author, bestie, listen β€” you should not care even a little bit about which event loop is gonna end up being used. Not your problem, not your business, don't worry about it. Just use the Promises module directly and let the universe sort out the backend:

package MyClass;

use Promises qw(deferred collect);

See? Clean. Iconic. No event loop named anywhere. 🫢

And then the end users of the module β€” the people actually running the app β€” they get to pick which backend is in play at the very start of the application:

use Promises -backend => ['Mojo'];
use MyClass;

That's the whole thing. They say the word, the backend shows up, everyone's happy. ✨

⚠️ Note, and this one matters: if you are using Mojolicious with the EV event loop, then you should use the Promises::Deferred::EV backend instead. Do not come for this backend in that situation, fr fr. Use the EV one. πŸ™ˆ

πŸ‘‘ AUTHOR πŸ‘‘

Stevan Little <stevan.little@iinteractive.com> β€” the author, the legend, the one who did this πŸ’–


This software is copyright (c) 2025, 2017, 2014, 2012 by Infinity Interactive, Inc. πŸŽ€

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. So like, go forth, remix, redistribute, it's all above board bestie πŸ’…


and that's the whole page, mwah 😘 β€” this was Promise...d::Mojo(3) from perl v5.42.0, dated 2025-07-25, delivered to you with love, glitter, and zero skipped options because there weren't any options to skip πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from