natural-apptitude / ngrx-store-ionic-storage

Simple syncing between @ngrx/store and Ionic Storage.
MIT License
66 stars 26 forks source link

Provide better error logging when failing to hydrate the store #8

Closed okonon closed 6 years ago

okonon commented 7 years ago

@fiznool @dfmartin please merge if you have time. The default hardcoded error message is not specific enough. I ran into issues when i had a syntax error but got hardcoded error instead real one in console output.

joewoodhouse commented 7 years ago

Would it not be better to append e onto the log as well, just in case it is useful?

okonon commented 7 years ago

I think, as a developer, you can take provide custom error handling I onError function:

export function onSyncError(err) {
  console.log(err);
}

export const reducers: ActionReducerMap<appState> = {
  books: booksReducer,
  collection: collectionReducer
};

export const storageSyncReducer = storageSync({
  keys: ['collection'],   // Only sync the `collection` state
  ignoreActions: [        // Don't sync when these actions occur
    BookActions.SELECT,
    CollectionActions.FILTER,
  ],
  hydratedStateKey: 'hydrated', // Add this key to the state
  onSyncError: onSyncError      // If a sync fails
});
okonon commented 7 years ago

@joewoodhouse doen - appended error

joewoodhouse commented 6 years ago

Will be fixed in 4.2.0