-
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 message-pane actions style
BREAKING CHANGE: Due to an improvement on how actions are defined, the enum `StarkMessagePaneActionsTypes` became obsolete so it has been removed. As a result, the following actions have been changed: - `StarkAddMessages(public messages: StarkMessage[])` -> `StarkMessagePaneActions.addMessages({ messages: StarkMessage[] })` - `StarkRemoveMessages(public messages: StarkMessage[])` -> `StarkMessagePaneActions.removeMessages({ messages: StarkMessage[] })` - `StarkClearMessages()` -> `StarkMessagePaneActions.clearMessages()` - `StarkGetAllMessages()` -> `StarkMessagePaneActions.getAllMessages()` And also the previous union type has been replaced: `StarkMessagePaneActions` -> `StarkMessagePaneActions.Types`. Change in effect: ```typescript // Before @effect({ dispatch: false }) public starkAddMessages$(): Observable<void> { return this.actions$.pipe( ofType<StarkAddMessages>(StarkMessagePaneActionsTypes.ADD_MESSAGES), map((action: StarkAddMessages) => { // some logic }) ); } // After public starkAddMessages$ = createEffect( () => this.actions$.pipe( ofType(StarkMessagePaneActions.addMessages), map((action) => { // some logic }) ), { dispatch: false } ); ``` Change in `action` usage: ```typescript // Before this.store.dispatch(new StarkAddMessages(messages)); // After this.store.dispatch(StarkMessagePaneActions.addMessages({ messages: messages })); ```
- Loading branch information
1 parent
374c429
commit 3ff099f
Showing
15 changed files
with
111 additions
and
122 deletions.
There are no files selected for viewing
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/message-pane.actions"; | ||
import * as StarkMessagePaneActions from "./actions/message-pane.actions"; | ||
export { StarkMessagePaneActions }; |
63 changes: 18 additions & 45 deletions
63
packages/stark-ui/src/modules/message-pane/actions/message-pane.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,66 +1,39 @@ | ||
import { Action } from "@ngrx/store"; | ||
import { createAction, props, union } from "@ngrx/store"; | ||
import { StarkMessage } from "../../../common/message"; | ||
|
||
/** | ||
* Actions related to stark message pane service | ||
* @ignore | ||
*/ | ||
export enum StarkMessagePaneActionTypes { | ||
ADD_MESSAGES = "[StarkMessagePane] Add Messages", | ||
REMOVE_MESSAGES = "[StarkMessagePane] Remove Messages", | ||
CLEAR_MESSAGES = "[StarkMessagePane] Clear Messages", | ||
GET_ALL_MESSAGES = "[StarkMessagePane] Get All Messages" | ||
} | ||
const actionKey = "StarkMessagePane"; | ||
|
||
/** | ||
* Triggered when the addMessages() method is called. | ||
* | ||
* Parameter: | ||
* - messages - The messages to add. | ||
*/ | ||
export class StarkAddMessages implements Action { | ||
/** | ||
* The type of action | ||
*/ | ||
public readonly type: StarkMessagePaneActionTypes.ADD_MESSAGES = StarkMessagePaneActionTypes.ADD_MESSAGES; | ||
|
||
/** | ||
* Class constructor | ||
* @param messages - The messages to add. | ||
*/ | ||
public constructor(public messages: StarkMessage[]) {} | ||
} | ||
export const addMessages = createAction(`[${actionKey}] Add Messages`, props<{ messages: StarkMessage[] }>()); | ||
|
||
/** | ||
* Triggered when the removeMessages() method is called. | ||
* | ||
* Parameter: | ||
* - messages - The messages to remove. | ||
*/ | ||
export class StarkRemoveMessages implements Action { | ||
/** | ||
* The type of action | ||
*/ | ||
public readonly type: StarkMessagePaneActionTypes.REMOVE_MESSAGES = StarkMessagePaneActionTypes.REMOVE_MESSAGES; | ||
|
||
/** | ||
* Class constructor | ||
* @param messages - The messages to remove. | ||
*/ | ||
public constructor(public messages: StarkMessage[]) {} | ||
} | ||
export const removeMessages = createAction(`[${actionKey}] Remove Messages`, props<{ messages: StarkMessage[] }>()); | ||
|
||
/** | ||
* Triggered when the clearMessages() method is called. | ||
*/ | ||
export class StarkClearMessages implements Action { | ||
/** | ||
* The type of action | ||
*/ | ||
public readonly type: StarkMessagePaneActionTypes.CLEAR_MESSAGES = StarkMessagePaneActionTypes.CLEAR_MESSAGES; | ||
} | ||
export const clearMessages = createAction(`[${actionKey}] Clear Messages`); | ||
|
||
/** | ||
* Triggered when the getAllMessages() method is called. | ||
*/ | ||
export class StarkGetAllMessages implements Action { | ||
/** | ||
* The type of action | ||
*/ | ||
public readonly type: StarkMessagePaneActionTypes.GET_ALL_MESSAGES = StarkMessagePaneActionTypes.GET_ALL_MESSAGES; | ||
} | ||
export const getAllMessages = createAction(`[${actionKey}] Get All Messages`); | ||
|
||
export type StarkMessagePaneActions = StarkAddMessages | StarkRemoveMessages | StarkClearMessages | StarkGetAllMessages; | ||
/** | ||
* @ignore | ||
*/ | ||
const all = union({ addMessages, removeMessages, clearMessages, getAllMessages }); | ||
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 { starkMessagePaneStoreKey } from "./constants/message-pane-store-key"; |
4 changes: 4 additions & 0 deletions
4
packages/stark-ui/src/modules/message-pane/constants/message-pane-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 starkMessagePaneStoreKey = "StarkMessagePane"; |
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
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/messages-pane.reducer"; | ||
export { selectStarkMessages, starkMessagesReducers, StarkMessageState } from "./reducers/index"; | ||
export { messagesReducer } from "./reducers/messages-pane.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
Oops, something went wrong.