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

Add support for ngrx store 6 -> 7 migration #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zbarbuto
Copy link

@zbarbuto zbarbuto commented Apr 26, 2019

Hopefully this isn't too out of scope for what this tool was designed for.

I've had a few projects I've had to migrate which make extensive use of NgRX for state management. Because the ofType and select operators aren't RxJS operators none of my @Effects or store selectors fully migrated to RxJS 6 style piped operators.

This simple change means that this tool becomes an rxjs-5-to-6 as well as ngrx-6-to-7 migration tool.

Migrates:

this.store.select(selector)

// to
import { select } from '@ngrx/store';

this.store.pipe( select(selector) );

and

this.actions$.ofType([SomeType])

// to
import { ofType } from '@ngrx/store';

this.actions$.pipe( ofType([SomeType]) )

if (type.symbol !== undefined && type.symbol.name === 'Observable') {
if (
type.symbol !== undefined &&
(type.symbol.name === 'Observable' || type.symbol.name === 'Store')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW Store, despite being Observable-like doesn't actually resolve to the Observable type.

@zbarbuto
Copy link
Author

zbarbuto commented Apr 26, 2019

Worth noting also that this will only work if you have not yet updated your @ngrx/* packages to the lates version.

If you do that first, the .ofType method won't exist and it won't be able to resolve actions$ to an Observable type (I found this out the hard way)

@zbarbuto zbarbuto changed the title Add support for ngrx store 6 -> 7 migration WIP: Add support for ngrx store 6 -> 7 migration Apr 29, 2019
@zbarbuto zbarbuto changed the title WIP: Add support for ngrx store 6 -> 7 migration Add support for ngrx store 6 -> 7 migration May 7, 2019
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

Successfully merging this pull request may close these issues.

1 participant