ngrx Angular app not working unless Redux Devtools is installed

ngrx Angular app not working unless Redux Devtools is installed



Our ngrx Angular app works great until we uninstall Redux Devtools at which point we get errors:



You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.



Store setup looks like this in app.module.ts:


StoreModule.forRoot(reducers, metaReducers),
!environment.production ? StoreDevtoolsModule.instrument() : ,
EffectsModule.forRoot([SimsEffects, FiltersEffects, OmnipresentEffects, UserEffects, InitEffects]),
StoreRouterConnectingModule.forRoot(stateKey: 'router')



and our ngrx reducers/index.ts file looks like this:


export interface AppState
router: any,
omnipresent: OmnipresentState,
user: UserState


export const reducers: ActionReducerMap<AppState> =
router: routerReducer,
omnipresent: omnipresentReducer,
user: userReducer


export function resetStore(reducer)
return (state, action) =>
return reducer(action.type === InitActionTypes.ResetStore ? undefined : state, action)



// storeFreeze throws an error early if state is mutated, avoiding hard to debug state mutation issues
export const metaReducers: MetaReducer<AppState> = !environment.production ? [resetStore, storeFreeze] : [resetStore] // tslint:disable-line array-type



Anyone experienced this before or knows the fix? The issue exists both in dev and prod environments.



We are running Node v8.11.3



EDIT: If I comment out this line, the error goes away, but obviously the store fails to init:


@Effect()
init$: Observable<any> = defer(() =>
return of(new InitAction())
)



Where InitAction is simply an action that does nothing with no effect attached (for the purpose of helping to debug this).





Just out of curiousity, where did you learn to use effects like that? To me this pattern seems completely off. As far as I know you always have to import Actions and then use the ofType method to listen to particular actions to determine the to be executed effect.
– enf0rcer
Aug 21 at 12:06


Actions


ofType





that sounds right, but not for the init effect - see docs - github.com/ngrx/platform/blob/master/docs/effects/…
– danday74
Aug 21 at 12:49




1 Answer
1



Changing this solved it:


import defer, of from 'rxjs/index' // as per my IDE suggestions



to:


import defer, of from 'rxjs' // as per ngrx docs



Also, replaced all references to 'rxjs/index' with 'rxjs'





Glad you found the problem, that's a weird suggestion from your IDE.
– enf0rcer
Aug 21 at 14:21





yah, even weirder that it worked with DevTools on! anyway looks like I might not get sacked after all ;)
– danday74
Aug 21 at 14:29







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế