MessageBus

Message Bus is a low level API used to communicate between the UI and the background. Communication is based on a channel abstraction. Messages published in a given channel to one MessageBusSink are received on the same channel by the corresponding MessageBusSource.

      
      abstract class MessageBus implements MessageBusSource, MessageBusSink {
  abstract initChannel(channel: string, runInZone?: boolean): void
  abstract attachToZone(zone: NgZone): void
  abstract from(channel: string): EventEmitter<any>
  abstract to(channel: string): EventEmitter<any>
}
    

方法

Sets up a new channel on the MessageBus. MUST be called before calling from or to on the channel. If runInZone is true then the source will emit events inside the angular zone and the sink will buffer messages and send only once the zone exits. if runInZone is false then the source will emit events inside the global zone and the sink will send messages immediately.

abstract initChannel(channel: string, runInZone?: boolean): void
      
      abstract initChannel(channel: string, runInZone?: boolean): void
    
参数
channel string
runInZone boolean

可选. 默认值是 undefined.

返回值

void

Assigns this bus to the given zone. Any callbacks attached to channels where runInZone was set to true on initialization will be executed in the given zone.

abstract attachToZone(zone: NgZone): void
      
      abstract attachToZone(zone: NgZone): void
    
参数
zone NgZone
返回值

void

Returns an EventEmitterthat emits every time a message is received on the given channel.

abstract from(channel: string): EventEmitter<any>
      
      abstract from(channel: string): EventEmitter<any>
    
参数
channel string
返回值

EventEmitter<any>

Returns an EventEmitterfor the given channel To publish methods to that channel just call next on the returned emitter

abstract to(channel: string): EventEmitter<any>
      
      abstract to(channel: string): EventEmitter<any>
    
参数
channel string
返回值

EventEmitter<any>