JSFiddle - React, Tailwind, and code Playground

JavaScript

//*********** MANAGEMENT CACHE

function MyCache(){
  this.Write = function(name, value){
    if(this.Test()) window.localStorage = {};
    value = { val : value }
    window.localStorage[name] = JSON.stringify(value);
  }

  this.Read = function (name){
    if(this.Test()) window.localStorage = {};
    if(!window.localStorage[name]) return '';
    var value = JSON.parse(window.localStorage[name]);
    return value.val;
  }

  this.Test = function(){
    return typeof Storage !== "undefined";
  }
};


//*********** SCHEDULER

var MySchedulerRequest = function(){}

MySchedulerRequest.prototype.isValidId = false;
MySchedulerRequest.prototype.id = false;
MySchedulerRequest.prototype.lastAction = new Date().getTime();
MySchedulerRequest.prototype.timeout = 250;
MySchedulerRequest.prototype.nameStorage = 'Scheduler_MyChat';
MySchedulerRequest.prototype.Fx = function(){};

MySchedulerRequest.prototype.Loop = function(self){

  var newLastAction = new Date().getTime();
  var EXlastAction = new MyCache().Read(self.GetNameStorage());

  if(!EXlastAction == ''){
    if(self.lastAction != EXlastAction) self.genId();
  }

  self.lastAction = newLastAction; 
  new MyCache().Write(self.GetNameStorage(), newLastAction);

  var tabList = self.GetListTab();
  for(var k in tabList){
    if((new Date().getTime() - tabList[k]) > (self.timeout * 4)) window.localStorage.removeItem(k);
  }

  console.log(self.GetListTab());

  setTimeout(function(){ self.Loop(self); }, self.timeout);
}

MySchedulerRequest.prototype.GetListTab = function(){
  var list = {};
  for(var k in window.localStorage){
    if(k.substr(0,this.nameStorage.length) == this.nameStorage) list[k] = new MyCache().Read(k);
  }
  return list;
}

MySchedulerRequest.prototype.GetNameStorage = function(){
  return this.nameStorage + this.id;
}

MySchedulerRequest.prototype.genId = function(){
  this.id = new Date().getTime();
  return this;
}

MySchedulerRequest.prototype.Run = function(){
  this.genId();
 ...