Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 4x 4x 4x 4x 4x 4x 4x 4x 4x 5x 5x 5x 5x 5x 6x 6x 5x 5x 3x | import { Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { Store, select } from '@ngrx/store';
import { map, switchMap, take } from 'rxjs/operators';
import { whenFalsy } from 'ish-core/utils/operators';
import { StatePropertiesService } from 'ish-core/utils/state-transfer/state-properties.service';
import { CopilotEmbeddedConfig } from '../../models/copilot-embedded-config/copilot-embedded-config.model';
import { copilotEmbeddedConfigInternalActions } from './copilot-embedded-config.actions';
import { getCopilotEmbeddedConfig } from './copilot-embedded-config.selectors';
@Injectable()
export class CopilotEmbeddedConfigEffects {
constructor(
private actions$: Actions,
private store: Store,
private statePropertiesService: StatePropertiesService
) {}
loadCopilotEmbeddedConfig$ = createEffect(() =>
this.actions$.pipe(
ofType(copilotEmbeddedConfigInternalActions.loadCopilotEmbeddedConfig),
switchMap(() =>
this.statePropertiesService
.getStateOrEnvOrDefault<CopilotEmbeddedConfig>('COPILOT_EMBEDDED', 'copilotEmbedded')
.pipe(
take(1),
map(config => copilotEmbeddedConfigInternalActions.setCopilotEmbeddedConfig({ config }))
)
)
)
);
loadCopilotEmbeddedConfigOnInit$ = createEffect(() =>
this.store.pipe(
select(getCopilotEmbeddedConfig),
whenFalsy(),
map(() => copilotEmbeddedConfigInternalActions.loadCopilotEmbeddedConfig())
)
);
}
|