-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stark-ui): update progress-indicator actions style
BREAKING CHANGE: Due to an improvement on how actions are defined, the enum `StarkProgressIndicatorActionsTypes` became obsolete so it has been removed. As a result, the following actions have been changed: - `StarkProgressIndicatorRegister(public progressIndicatorConfig: StarkProgressIndicatorFullConfig )` -> `StarkProgressIndicatorActions.register({ progressIndicatorConfig: StarkProgressIndicatorFullConfig })` - `StarkProgressIndicatorDeregister(public topic: string)` -> `StarkProgressIndicatorActions.deregister({ topic: string })` - `StarkProgressIndicatorHide(public topic: string)` -> `StarkProgressIndicatorActions.hide({ topic: string })` - `StarkProgressIndicatorShow(public topic: string)` -> `StarkProgressIndicatorActions.show({ topic: string })` And also the previous union type has been replaced: `StarkProgressIndicatorActions` -> `StarkProgressIndicatorActions.Types`. Change in effect: ```typescript // Before @effect({ dispatch: false }) public starkProgressIndicatorShow$(): Observable<void> { return this.actions$.pipe( ofType<StarkProgressIndicatorShow>( StarkProgressIndicatorActionsTypes.PROGRESS_INDICATOR_SHOW ), map((action: StarkProgressIndicatorShow) => { // some logic }) ); } // After public starkProgressIndicatorShow$ = createEffect( () => this.actions$.pipe( ofType(StarkProgressIndicatorActions.show), map((action) => { // some logic }) ), { dispatch: false } ); ``` Change in `action` usage: ```typescript // Before this.store.dispatch(new StarkProgressIndicatorShow(topic)); // After this.store.dispatch(StarkProgressIndicatorActions.show({ topic: topic })); ```
- Loading branch information
1 parent
97b067d
commit 374c429
Showing
16 changed files
with
228 additions
and
245 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./actions/progress-indicator.actions"; | ||
import * as StarkProgressIndicatorActions from "./actions/progress-indicator.actions"; | ||
export { StarkProgressIndicatorActions }; |
94 changes: 26 additions & 68 deletions
94
packages/stark-ui/src/modules/progress-indicator/actions/progress-indicator.actions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,44 @@ | ||
import { Action } from "@ngrx/store"; | ||
import { createAction, props, union } from "@ngrx/store"; | ||
import { StarkProgressIndicatorFullConfig } from "../entities"; | ||
|
||
/** | ||
* Progress indicator action types enumeration | ||
*/ | ||
export enum StarkProgressIndicatorActionTypes { | ||
PROGRESS_INDICATOR_REGISTER = "PROGRESS_INDICATOR_REGISTER", | ||
PROGRESS_INDICATOR_DEREGISTER = "PROGRESS_INDICATOR_DEREGISTER", | ||
PROGRESS_INDICATOR_HIDE = "PROGRESS_INDICATOR_HIDE", | ||
PROGRESS_INDICATOR_SHOW = "PROGRESS_INDICATOR_SHOW" | ||
} | ||
import { starkProgressIndicatorStoreKey } from "../constants"; | ||
|
||
/** | ||
* Triggered by the {@link StarkProgressIndicatorService} register() method. | ||
* | ||
* Parameter: | ||
* - progressIndicatorConfig - Configuration of the indicator | ||
*/ | ||
export class StarkProgressIndicatorRegister implements Action { | ||
/** | ||
* The type of action | ||
*/ | ||
public readonly type: StarkProgressIndicatorActionTypes.PROGRESS_INDICATOR_REGISTER = | ||
StarkProgressIndicatorActionTypes.PROGRESS_INDICATOR_REGISTER; | ||
|
||
/** | ||
* Class constructor | ||
* @param progressIndicatorConfig - Configuration of the indicator | ||
*/ | ||
public constructor(public progressIndicatorConfig: StarkProgressIndicatorFullConfig) {} | ||
} | ||
export const register = createAction( | ||
`[${starkProgressIndicatorStoreKey}] Register`, | ||
props<{ progressIndicatorConfig: StarkProgressIndicatorFullConfig }>() | ||
); | ||
|
||
/** | ||
* Triggered by the {@link StarkProgressIndicatorService} deregister() method. | ||
* | ||
* Parameter: | ||
* - topic - The topic of the indicator | ||
*/ | ||
export class StarkProgressIndicatorDeregister implements Action { | ||
/** | ||
* The type of action | ||
*/ | ||
public readonly type: StarkProgressIndicatorActionTypes.PROGRESS_INDICATOR_DEREGISTER = | ||
StarkProgressIndicatorActionTypes.PROGRESS_INDICATOR_DEREGISTER; | ||
|
||
/** | ||
* Class constructor | ||
* @param topic - The topic of the indicator | ||
*/ | ||
public constructor(public topic: string) {} | ||
} | ||
export const deregister = createAction(`[${starkProgressIndicatorStoreKey}] Deregister`, props<{ topic: string }>()); | ||
|
||
/** | ||
* Triggered by the {@link StarkProgressIndicatorService} hide() method. | ||
* | ||
* Parameter: | ||
* - topic - The topic of the indicator | ||
*/ | ||
export class StarkProgressIndicatorHide implements Action { | ||
/** | ||
* The type of action | ||
*/ | ||
public readonly type: StarkProgressIndicatorActionTypes.PROGRESS_INDICATOR_HIDE = | ||
StarkProgressIndicatorActionTypes.PROGRESS_INDICATOR_HIDE; | ||
|
||
/** | ||
* Class constructor | ||
* @param topic - The topic of the indicator | ||
*/ | ||
public constructor(public topic: string) {} | ||
} | ||
export const hide = createAction(`[${starkProgressIndicatorStoreKey}] Hide`, props<{ topic: string }>()); | ||
|
||
/** | ||
* Triggered by the {@link StarkProgressIndicatorService} show() method. | ||
* | ||
* Parameter: | ||
* - topic - The topic of the indicator | ||
*/ | ||
export class StarkProgressIndicatorShow implements Action { | ||
/** | ||
* The type of action | ||
*/ | ||
public readonly type: StarkProgressIndicatorActionTypes.PROGRESS_INDICATOR_SHOW = | ||
StarkProgressIndicatorActionTypes.PROGRESS_INDICATOR_SHOW; | ||
|
||
/** | ||
* Class constructor | ||
* @param topic - The topic of the indicator | ||
*/ | ||
public constructor(public topic: string) {} | ||
} | ||
export const show = createAction(`[${starkProgressIndicatorStoreKey}] Show`, props<{ topic: string }>()); | ||
|
||
export type StarkProgressIndicatorActions = | ||
| StarkProgressIndicatorRegister | ||
| StarkProgressIndicatorDeregister | ||
| StarkProgressIndicatorHide | ||
| StarkProgressIndicatorShow; | ||
/** | ||
* @ignore | ||
*/ | ||
const all = union({ register, deregister, hide, show }); | ||
export type Types = typeof all; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./constants/progress-indicator-store-key"; |
4 changes: 4 additions & 0 deletions
4
packages/stark-ui/src/modules/progress-indicator/constants/progress-indicator-store-key.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* Key defined to find the service in a store | ||
*/ | ||
export const starkProgressIndicatorStoreKey = "StarkProgressIndicator"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from "./reducers/index"; | ||
export * from "./reducers/progress-indicator.reducer"; | ||
export { selectStarkProgressIndicator, starkProgressIndicatorReducers, StarkProgressIndicatorState } from "./reducers/index"; | ||
export { progressIndicatorReducer } from "./reducers/progress-indicator.reducer"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.