I faced the same challenge and eventually found a solution.
main.ts
, use provideEffects([EffectSources])
EffectSources
addEffects
function from EffectSources
and pass the instance of your effectSee the code snippets below
// main.ts
import { EffectSources, provideEffects } from '@ngrx/effects';
bootstrapApplication(AppComponent, {
providers: [
// your providers here
provideEffects([EffectSources]),
]
});
// your-effect.ts
@Injectable({
providedIn: 'root',
})
export class YourEffect {}
// your-component.ts
@Component({
selector: 'app-selector',
standalone: true,
})
export class YourComponent {
constructor(
private effectSources: EffectSources,
private yourEffect: YourEffect,
) {
effectSources.addEffects(yourEffect)
}
}