Subject is a tool object in Rxjs.
Subject is a special type of Observable that allows the value to be multicast to many observers. Subject is like EventEmitters.
Each Subject is Observable and Observer. You can subscribe to a topic, and you can call next for feed values as well as errors and completions.
This attribute is defined on Popover Component:
The assignment operation takes place in the code of Popover Directive:
When the Close button of Popover Component is triggered by the mouse or keyboard, the registered close event handler is triggered:
In the close event processing function, the CLOSE_BUTTON_CLICK or CLOSE_BUTTON_KEYDOWN event is broadcast to its listeners through the Subject.
All events that can trigger the shutdown of Popover Component are defined in Popover Directive, as shown in the figure above.
Popover Directive is the listener for these events.
There are two problems here:
- When is handlePopverEvents called by?
- Why is Directive's close function responsible for closing Popover Component?
For the first question, the clues can be seen here: the eventSubject of Popover Directive is responsible for monitoring events, and then this eventSubject instance is assigned to the Component instance, which is responsible for sending the event:
close operation:
If you comment out line 155 of the above figure, you cannot close Popover Component:
More original articles by Jerry, all in: "Wang Zixi":
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。