Answer the question
In order to leave comments, you need to log in
How to implement the mediator pattern in this case?
I have three independent modules: working with Redis, working with a database and working with a telegram bot. I want to connect them with each other using the mediator pattern and I don’t quite understand how to do it correctly.
The bot receives a message from the user, and I need to:
1) write data to the database ( db.save(data, table)
)
2) write data to Redis ( redis.saveSession(id, level)
)
3) reply to the user ( )
And how to do this?
The standard option is not suitable, since you need to pass three different functions that take a different number of input parametersapp.sendMessage(id, 'text')
const mediator = new Mediator();
mediator.on('event', someFunc); //не подходит
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question