JSFiddle - React, Tailwind, and code Playground

JavaScript

function AlertCollection(){
    
    this.poll = function(){
         var process = function(items){
             return items.map(function(i){ return new Alert(i);})
         }
      
        var message = new MessageHandler();
        return message.request()
                 .then(process)
                 .then(this.filteredAlerts)
                 .then(this.pollDeliverance);
    }
    
    this.filteredAlerts = function(alerts){
        // to demo, just return alerts starting "F"
        return alerts.filter(function(a){ return a.value[0] == "F"});
    }
    this.pollDeliverance = function(alerts){
        return $.getJSON("/echo/json").then(function(){
            alerts.forEach(function(a){
               a.value += "_Delivered";
            });
            return alerts;
        })
    }
}

function MessageHandler(){
 	
  this.request = function(){
        return $.getJSON("/echo/json").then(function(){
            return ["Foo","Bar"]
        });
  }
 
}

function Alert(val){
    this.value = val;
}

var ac = new AlertCollection();
ac.poll().then(function(alerts){
    console.log(alerts);
})