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-components with REMOTE_COMPONENT_CONFIG import from @onecx/angular-utils

  • For each remote component update import REMOTE_COMPONENT_CONFIG from @onecx/angular-remote-components to @onecx/angular-utils

  • For each remote component update import for RemoteComponentConfig from @onecx/angular-remote-components to @onecx/angular-utils

Update component code

  • Replace BASE_URL in component’s providers array to REMOTE_COMPONENT_CONFIG

  • Replace BASE_URL in component’s constructor injection to REMOTE_COMPONENT_CONFIG

  • Replace BASE_URL type ReplaySubject<string> to REMOTE_COMPONENT_CONFIG type ReplaySubject<RemoteComponentConfig>

Example

Before
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>
  )
}
After
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>
  )
}