Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compat NgRx Store #8

Open
rainerhahnekamp opened this issue Jan 3, 2024 · 2 comments
Open

Compat NgRx Store #8

rainerhahnekamp opened this issue Jan 3, 2024 · 2 comments

Comments

@rainerhahnekamp
Copy link
Collaborator

Check if it is possible to integrate an existing NgRx Store into withRedux.

Coming from NgRx Store

const flightsFeature = createFeature({
  name: 'flights', 
  reducer: createReducer(initialState, on(flightActions.searched, (state, {flights}) => ({...state, flights})))
})

@Injectable()
class FlightEffects {
  search$ = createEffect(() => ofType(flightActions.search));
}

Could be integrated like

signalStore(
  {providedIn: 'root'},
  withReduxCompat(flightsFeature, FlightEffects)
);
@rosostolato
Copy link

According to my tests while I was developing this lib, if you inject the effects in the store, you will have circular dependency injections if you try to inject the store on your effects class.

The best solution I found was to create this provider function that would inject the Effects when you use it with the EffectsDirective.

@rainerhahnekamp
Copy link
Collaborator Author

In that case, the FlightEffect still goes against the @ngrx/store Store service and not against the SignalStore. I guess with your provider function, one could replace it under the hood.

So the effect would think it is working with the Store service although it runs against an adapter which uses the SignalStore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants