JSFiddle - React, Tailwind, and code Playground

by Jussia

JavaScript

var service = {
	ids: [1,5,8,9,15],
  handlers: [],
	addHandler: function (handler) {
  	this.handlers.push(handler)
  },
  addId: function (id) {
  	this.ids.push(id)
  	this.notify(id)
  },
  notify: function (id) {
  	for (var i = 0; i < this.handlers.length; i++) {
      	this.handlers[i](id)
    }
  }
}

function checkIsInBan(id) {
	console.log(id, "is not in ban")
}

function checkIsSubscribe(id) {
	console.log(id, "is subsctibe")
}

function checkIsHasEmail(id) {
	console.log(id, "has email")
}

service.addHandler(checkIsInBan)
service.addHandler(checkIsSubscribe)
service.addHandler(checkIsHasEmail)
service.addId(3)