1
by Artem
JavaScript
class MagazinePublisher {
constructor(stores) {
this.stores = stores;
}
publishNewMagazine() {
const newMagazine = {
date: new Date(),
title: ‘Breaking News’
};
this.magazines.push(newMagazine);
this.store.forEach((store) => {
store.notify(‘new - magazine’, newMagazine);
});
}
}
/*
обычно решают заменой на пабсаб
типа
pubsub.notify(‘new-magazine’, newMagazine);
const store1 = new Store();
store1.on(‘new-magazine’, () => {
constole.log(’sell’);
})
*/