T - Indicates the publisher type.public abstract class Publisher<T> extends Object
This class provides a list of subscribers as well as three abstract interfaces for registering a subscriber, deregister a subscriber, and deregister all subscribers. You can call the child interfaces of the three abstract interfaces to manage subscriber registrations.
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
protected List<T> |
mSubscribers |
Indicates the subscriber list variable.
|
| 构造器 | 说明 |
|---|---|
Publisher() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
registerSubscriber(T subscriber) |
Registers subscribers with the subscriber list.
|
void |
unregisterSubscriber(long subscriber) |
Removes a subscriber from the subscriber list.
|
void |
unregisterSubscriber(T subscriber) |
Removes an subscriber from the subscriber list.
|
public void registerSubscriber(T subscriber)
This method is used to register multiple subscribers of the same type so that the subscribers' interfaces can be called in an uniform manner to handle changes on observed objects.
subscriber - Indicates the subscriber variable.public void unregisterSubscriber(T subscriber)
This method is used to deregister an subscriber by removing it from the subscriber list. A deregistered subscriber cannot perceive changes made for its observed objects.
subscriber - Indicates the subscriber variable.public void unregisterSubscriber(long subscriber)
This method is used to deregister a subscriber by removing it from the subscriber list. A deregistered subscriber cannot perceive changes made for its observed objects.
subscriber - Indicates the subscriber native pointer.