diff --git a/projects/ngx-view-state/CHANGELOG.md b/projects/ngx-view-state/CHANGELOG.md index af596ca..fef6f2b 100644 --- a/projects/ngx-view-state/CHANGELOG.md +++ b/projects/ngx-view-state/CHANGELOG.md @@ -1,5 +1,12 @@ ## Changelog +## 2.0.0 + +- Rename ViewStateActionsConfig properties + - `resetLoadingOn` to `resetOn` + - `error` to `errorOn` + + ## 1.0.2 - Update peerDependencies and keywords diff --git a/projects/ngx-view-state/README.md b/projects/ngx-view-state/README.md index 4cfbfd8..abb1443 100644 --- a/projects/ngx-view-state/README.md +++ b/projects/ngx-view-state/README.md @@ -63,13 +63,13 @@ constructor(private actions$: Actions, private viewStateActionsService: ViewStat this.viewStateActionsService.add([ { startLoadingOn: TodosActions.loadTodos, - resetLoadingOn: [TodosActions.loadTodosSuccess], - error: [TodosActions.loadTodosFailure] + resetOn: [TodosActions.loadTodosSuccess], + errorOn: [TodosActions.loadTodosFailure] }, { startLoadingOn: TodosActions.addTodo, - resetLoadingOn: [TodosActions.addTodoSuccess], - error: [TodosActions.addTodoFailure] + resetOn: [TodosActions.addTodoSuccess], + errorOn: [TodosActions.addTodoFailure] }, // Update and delete actions can be added in the same way ]); diff --git a/projects/ngx-view-state/package.json b/projects/ngx-view-state/package.json index aee046a..7b3d5d8 100644 --- a/projects/ngx-view-state/package.json +++ b/projects/ngx-view-state/package.json @@ -1,6 +1,6 @@ { "name": "ngx-view-state", - "version": "1.0.2", + "version": "2.0.0", "license": "MIT", "description": "ngx-view-state is a library for managing the Loading/Success/Error states of views in Angular applications that use Ngrx or HttpClient", "author": "Yurii Khomitskyi ", diff --git a/projects/ngx-view-state/src/lib/view-state/factories/error-view-status.ts b/projects/ngx-view-state/src/lib/view-state/factories/error-view-status.ts deleted file mode 100644 index c31116b..0000000 --- a/projects/ngx-view-state/src/lib/view-state/factories/error-view-status.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ViewStatusEnum } from '../models/view-status.enum'; -import { ViewError } from '../models/view-status.model'; - -export function errorViewStatus(error?: E): ViewError { - return { - type: ViewStatusEnum.ERROR, - error, - }; -} diff --git a/projects/ngx-view-state/src/lib/view-state/factories/idle-view-status.ts b/projects/ngx-view-state/src/lib/view-state/factories/idle-view-status.ts deleted file mode 100644 index 041e828..0000000 --- a/projects/ngx-view-state/src/lib/view-state/factories/idle-view-status.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ViewStatusEnum } from '../models/view-status.enum'; -import { ViewIdle } from '../models/view-status.model'; - -export function idleViewStatus(): ViewIdle { - return { - type: ViewStatusEnum.IDLE, - }; -} diff --git a/projects/ngx-view-state/src/lib/view-state/factories/index.ts b/projects/ngx-view-state/src/lib/view-state/factories/index.ts index 3edc1dc..ab84acf 100644 --- a/projects/ngx-view-state/src/lib/view-state/factories/index.ts +++ b/projects/ngx-view-state/src/lib/view-state/factories/index.ts @@ -1,4 +1,31 @@ -export { idleViewStatus } from './idle-view-status'; -export { loadingViewStatus } from './loading-view-status'; -export { loadedViewStatus } from './loaded-view-status'; -export { errorViewStatus } from './error-view-status'; +import { ViewError, ViewIdle, ViewLoaded, ViewLoading } from '../models/view-status.model'; +import { ViewStatusEnum } from '../models/view-status.enum'; + + +export function loadingViewStatus(): ViewLoading { + return { type: ViewStatusEnum.LOADING }; +} + +export function idleViewStatus(): ViewIdle { + return { + type: ViewStatusEnum.IDLE, + }; +} + +export function loadedViewStatus(): ViewLoaded { + return { + type: ViewStatusEnum.LOADED, + }; +} + +export function errorViewStatus(error?: E): ViewError { + return { + type: ViewStatusEnum.ERROR, + error, + }; +} + + + + + diff --git a/projects/ngx-view-state/src/lib/view-state/factories/loaded-view-status.ts b/projects/ngx-view-state/src/lib/view-state/factories/loaded-view-status.ts deleted file mode 100644 index 3c1b177..0000000 --- a/projects/ngx-view-state/src/lib/view-state/factories/loaded-view-status.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ViewStatusEnum } from '../models/view-status.enum'; -import { ViewLoaded } from '../models/view-status.model'; - -export function loadedViewStatus(): ViewLoaded { - return { - type: ViewStatusEnum.LOADED, - }; -} diff --git a/projects/ngx-view-state/src/lib/view-state/factories/loading-view-status.ts b/projects/ngx-view-state/src/lib/view-state/factories/loading-view-status.ts deleted file mode 100644 index 3535e55..0000000 --- a/projects/ngx-view-state/src/lib/view-state/factories/loading-view-status.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { ViewStatusEnum } from '../models/view-status.enum'; -import { ViewLoading } from '../models/view-status.model'; - -export function loadingViewStatus(): ViewLoading { - return { type: ViewStatusEnum.LOADING }; -} diff --git a/projects/ngx-view-state/src/lib/view-state/services/view-state-actions.service.spec.ts b/projects/ngx-view-state/src/lib/view-state/services/view-state-actions.service.spec.ts index 23c9a76..ca9318a 100644 --- a/projects/ngx-view-state/src/lib/view-state/services/view-state-actions.service.spec.ts +++ b/projects/ngx-view-state/src/lib/view-state/services/view-state-actions.service.spec.ts @@ -13,8 +13,8 @@ describe('ViewStateActionsService', () => { const actionsConfig: ViewStateActionsConfig[] = [ { startLoadingOn: loadData, - resetLoadingOn: [loadDataSuccess], - error: [lodDataFailure], + resetOn: [loadDataSuccess], + errorOn: [lodDataFailure], }, ]; diff --git a/projects/ngx-view-state/src/lib/view-state/services/view-state-actions.service.ts b/projects/ngx-view-state/src/lib/view-state/services/view-state-actions.service.ts index 45083cb..60572b3 100644 --- a/projects/ngx-view-state/src/lib/view-state/services/view-state-actions.service.ts +++ b/projects/ngx-view-state/src/lib/view-state/services/view-state-actions.service.ts @@ -6,8 +6,8 @@ export type ActionsMapConfig = { viewState: 'startLoading' } | { viewState: 're export interface ViewStateActionsConfig { startLoadingOn: Action; - resetLoadingOn: Action[]; - error: Action[]; + resetOn: Action[]; + errorOn: Action[]; } @@ -46,11 +46,11 @@ export class ViewStateActionsService { actions.forEach((action: ViewStateActionsConfig) => { this.actionsMap.set(action.startLoadingOn.type, { viewState: 'startLoading' }); - action.resetLoadingOn.forEach((resetLoading: Action) => { + action.resetOn.forEach((resetLoading: Action) => { this.actionsMap.set(resetLoading.type, { viewState: 'resetLoading', actionType: action.startLoadingOn.type }); }); - action.error.forEach((errorAction: Action) => { + action.errorOn.forEach((errorAction: Action) => { this.actionsMap.set(errorAction.type, { viewState: 'error', actionType: action.startLoadingOn.type }); }); }); diff --git a/projects/ngx-view-state/src/lib/view-state/store/view-state.integration.spec.ts b/projects/ngx-view-state/src/lib/view-state/store/view-state.integration.spec.ts index 4a34357..c91c0d7 100644 --- a/projects/ngx-view-state/src/lib/view-state/store/view-state.integration.spec.ts +++ b/projects/ngx-view-state/src/lib/view-state/store/view-state.integration.spec.ts @@ -42,8 +42,8 @@ describe('ViewStateIntegration', () => { this.viewStateActionsService.add([ { startLoadingOn: DataActions.loadData, - resetLoadingOn: [DataActions.loadDataSuccess], - error: [DataActions.loadDataFailure], + resetOn: [DataActions.loadDataSuccess], + errorOn: [DataActions.loadDataFailure], }, ]); } diff --git a/src/app/todos/store/todos.effects.ts b/src/app/todos/store/todos.effects.ts index 6550ba3..ce01458 100644 --- a/src/app/todos/store/todos.effects.ts +++ b/src/app/todos/store/todos.effects.ts @@ -17,23 +17,23 @@ export class TodosEffects { this.viewStateActionsService.add([ { startLoadingOn: TodosActions.loadTodos, - resetLoadingOn: [TodosActions.loadTodosSuccess], - error: [TodosActions.loadTodosFailure] + resetOn: [TodosActions.loadTodosSuccess], + errorOn: [TodosActions.loadTodosFailure] }, { startLoadingOn: TodosActions.addTodo, - resetLoadingOn: [TodosActions.addTodoSuccess], - error: [TodosActions.addTodoFailure] + resetOn: [TodosActions.addTodoSuccess], + errorOn: [TodosActions.addTodoFailure] }, { startLoadingOn: TodosActions.updateTodo, - resetLoadingOn: [TodosActions.updateTodoSuccess], - error: [TodosActions.updateTodoFailure] + resetOn: [TodosActions.updateTodoSuccess], + errorOn: [TodosActions.updateTodoFailure] }, { startLoadingOn: TodosActions.deleteTodo, - resetLoadingOn: [TodosActions.deleteTodoSuccess], - error: [TodosActions.deleteTodoFailure] + resetOn: [TodosActions.deleteTodoSuccess], + errorOn: [TodosActions.deleteTodoFailure] } ]); }