Replace BASE_URL injection token
In OneCX v6, BASE_URL injection token has been removed and replaced by REMOTE_COMPONENT_CONFIG. Additionally the type of injection token has changed from string to RemoteComponentConfig for REMOTE_COMPONENT_CONFIG token. RemoteComponentConfig type contains the base url.
Update imports
-
For each remote component replace BASE_URL import from
@onecx/angular-remote-componentswithREMOTE_COMPONENT_CONFIGimport from@onecx/angular-utils -
For each remote component update import
REMOTE_COMPONENT_CONFIGfrom@onecx/angular-remote-componentsto@onecx/angular-utils -
For each remote component update import for
RemoteComponentConfigfrom@onecx/angular-remote-componentsto@onecx/angular-utils
Update component code
-
Replace
BASE_URLin component’s providers array toREMOTE_COMPONENT_CONFIG -
Replace
BASE_URLin component’s constructor injection toREMOTE_COMPONENT_CONFIG -
Replace
BASE_URLtypeReplaySubject<string>toREMOTE_COMPONENT_CONFIGtypeReplaySubject<RemoteComponentConfig>
Example
import { BASE_URL } from "@onecx/angular-remote-components";
@Component({
providers: [
{
provide: BASE_URL,
useValue: new ReplaySubject<string>(1)
}
]
})
export class Example {
constructor(
@Inject(BASE_URL) private readonly baseUrl: ReplaySubject<string>
)
}
import { REMOTE_COMPONENT_CONFIG, RemoteComponentConfig } from "@onecx/angular-utils";
@Component({
providers: [
{
provide: REMOTE_COMPONENT_CONFIG,
useValue: new ReplaySubject<RemoteComponentConfig>(1)
}
]
})
export class Example {
constructor(
@Inject(REMOTE_COMPONENT_CONFIG) private readonly remoteComponentConfig: ReplaySubject<RemoteComponentConfig>
)
}