Z
Z
zlodiak2019-06-10 09:56:37
OOP
zlodiak, 2019-06-10 09:56:37

What are events in IoC?

The principle of dependency inversion (IoC) is often illustrated with the following diagram:
oYukX.jpg
It shows that the principle itself is a collective concept, it is some result that can be achieved using the following techniques:
service-locator,
dependency injection (3 types),
delegation,
events
I understand all these techniques other than events. Please tell me what is the point

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
dkrylov, 2019-06-11
@dkrylov

the bottom line is that you don't have to write all the code in the same class if the system is modular and the code needs to be used from different modules.
For example, there are 2 modules, and you need to organize automatic interaction between them when an event occurs in one of the modules. For example, in module 1 we created an entity, and according to the task, some kind of entity should be created in module 2.
And so, in order not to use classes from module No. 1 in module No. 2 and vice versa, you can throw an event - for example entityCreated - this event (identifier, and possibly parameters) throws module 1, and module 2 must be subscribed to this event (this is whom how implemented). I did this - in the database table handlers, there are bundles of event ID => handler.
How to run event handlers - you can also do it in different ways)

A
Alexander, 2017-07-16
@kentuck1213

<p><img src="{{post.image.url }}"><p>

S
sim3x, 2017-07-16
@sim3x

{{post.image.url}}
image2Read about Normal Forms

S
Sama Samsonov, 2017-07-17
@samuser

{% load staticfiles %}

<img src="{% static "myexample.jpg" %}" alt="My image"/>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question