JSFiddle - React, Tailwind, and code Playground

JavaScript

(function ($) {

    $.fn.plug = (function () {
        var worker = {};
        var id = 0;
        var elementos = new Array();
        return function () {
            
            var xTempo = 2000;

            elementos.push('novo elemento e id: ' + id);
            worker[id] = elementos[id];
            id++;
            $.ajax( /* confi.*/ ).done(function (res) {
                fazAlgo(worker[id], true);
            }).fail(function (res) {
                fazAlgo(worker[id], false);
            }).always(function () {
                setTimeout(function () {
                    removeElemento(worker[id]);
                }, xTempo);
            });

            // sou obrigado a encrementar pois cada elemento tem que ter um identificador diferente

            var plugin = this;
            return this.each(function () {
                return plugin; // o que faz esta linha?
            });
        }
    })();
})(jQuery);

var plug = $.fn.plug();