[#BloombergLP-ball-BroadcastObserver-registerObserver]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/ball.adoc[ball]::xref:BloombergLP/ball/BroadcastObserver.adoc[BroadcastObserver]::registerObserver
:relfileprefix: ../../../
:mrdocs:

Add the specified `observer` with the specified `observerName` to the registry of this broadcast observer&period; Return 0 if `observer` was successfully registered, and a non&hyphen;zero value (with no effect) otherwise&period; Henceforth, this observer will forward each record it receives through its `publish` method, including the record&apos;s context, to the `publish` method of `observer`, until `observer` is deregistered&period; The behavior is undefined if a cyclic reference is created among registered observers&period; Note that this method will fail if an observer having `observerName` is already registered&period;

== Synopsis

Declared in `&lt;ball&lowbar;broadcastobserver&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
registerObserver(
    xref:bsl/shared_ptr-0a.adoc[bsl::shared&lowbar;ptr&lt;Observer&gt;] const& observer,
    std::string&lowbar;view const& observerName);
----


[.small]#Created with https://www.mrdocs.com[MrDocs]#
