Skip to content

wrong typing for injected DataPersistence service in generated Effects class #748

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

Closed
luchsamapparat opened this issue Sep 4, 2018 · 1 comment · Fixed by #774
Closed
Assignees
Labels

Comments

@luchsamapparat
Copy link
Contributor

I ran ng g ngrx dummy and this interface is generated in the reducer file:


export interface DummyState {
    list: Entity[]; // list of Dummy; analogous to a sql normalized table
    selectedId?: string | number; // which Dummy record has been selected
    loaded: boolean; // has the Dummy list been loaded
    error?: any; // last none error (if any)
}

The corresponding effects file looks like this:

    @Effect()
    loadDummy$ = this.dataPersistence.fetch(DummyActionTypes.LoadDummy, {
        run: (action: LoadDummy, state: DummyState) => {
            // Your custom REST 'load' logic goes here. For now just return an empty list...
            return new DummyLoaded([]);
        },

        onError: (action: LoadDummy, error) => {
            console.error("Error", error);
            return new DummyLoadError(error);
        }
    });

    constructor(
        private actions$: Actions,
        private dataPersistence: DataPersistence<DummyState>
    ) {}

The typing for the injected dataPersistence service as well as the typing in the run method indicate, that only the dummy part is passed to the run method.

However, the actual implementation uses the complete state:

.pipe(withLatestFrom(this.store), fetch(opts));

https://github.com/nrwl/nx/blob/master/packages/nx/src/data-persistence.ts#L369

I have an older Nx-based project where the typing has been generated correctly. There was an additional interface in the reducer that described the part of the app state the reducer was responsible for. So this seems to be a regression.

@ThomasBurleson ThomasBurleson self-assigned this Sep 10, 2018
@bcabanes bcabanes self-assigned this Sep 18, 2018
bcabanes added a commit to bcabanes/nx that referenced this issue Sep 18, 2018
This adds the `<%= className%>StoreState` used to type the store from the
`DataPersistence` methods.

close nrwl#748
bcabanes added a commit to bcabanes/nx that referenced this issue Sep 19, 2018
This adds the `<%= className%>PartialState` used to type the store from the
`DataPersistence` methods.
This adds the `XXX_FEATURE_KEY` to the `xxx.reducer.ts` file too.

close nrwl#748
bcabanes added a commit to bcabanes/nx that referenced this issue Sep 19, 2018
This adds the `<%= className%>PartialState` used to type the store from the
`DataPersistence` methods.
This adds the `XXX_FEATURE_KEY` to the `xxx.reducer.ts` file too.

close nrwl#748
bcabanes added a commit to bcabanes/nx that referenced this issue Sep 20, 2018
This adds the `<%= className%>PartialState` used to type the store from the
`DataPersistence` methods.
This adds the `XXX_FEATURE_KEY` to the `xxx.reducer.ts` file too.

close nrwl#748
vsavkin pushed a commit that referenced this issue Sep 28, 2018
This adds the `<%= className%>PartialState` used to type the store from the
`DataPersistence` methods.
This adds the `XXX_FEATURE_KEY` to the `xxx.reducer.ts` file too.

close #748
@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants