-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add FXIOS-9301 [Microsurvey] Redux proposed enhancements #20595
base: main
Are you sure you want to change the base?
Conversation
// let model = (action as? MicrosurveyPromptMiddlewareAction)?.microsurveyModel | ||
let model = action.payload as? MicrosurveyModel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OrlaM For demoing purposes, I added another commit to discuss using payload instead of our current implementation. The commented out code is to demonstrate what we are doing today. Currently, a lot of actions tend to use a singular built-in object types that we can pull from the payload (like we show here with MicrosurveyModel
.
I was curious in whether we also discussed a simple payload with Any?
type. The downside I see is that we may need to check the type as an extra step, but already do a lot of checks with the action types as well. For complex payloads, we can create a separate struct to associate with that specific action.
struct CloseTabPayload {
let panelType: panelType,
let tabUUID: tabUUID
}
let payload = CloseTabPayload(panelType: panelType,
tabUUID: tabUUID)
let action = TabPanelViewAction(windowUUID: windowUUID,
actionType: TabPanelViewActionType.closeTab,
payload: payload)
Let me know what you think! If this doesn't work, I'll go ahead and revert this commit and follow the conventions we have currently. Still investigating on generics, but that'll be separate from this PR if there's a good solution.
@@ -36,7 +40,8 @@ class MicrosurveyPromptMiddleware { | |||
private func initializeMicrosurvey(windowUUID: WindowUUID, model: MicrosurveyModel) { | |||
let newAction = MicrosurveyPromptMiddlewareAction( | |||
windowUUID: windowUUID, | |||
actionType: MicrosurveyPromptMiddlewareActionType.initialize(model) | |||
actionType: MicrosurveyPromptMiddlewareActionType.initialize, | |||
payload: model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In some ways this is sort of bringing us back to what we had previously, except that the payloads were previously concrete subclasses of ActionContext
and passed in as associated values. But we had used a similar idea of leveraging the benefits of inheritance in the custom payloads rather than having all of the properties declared on the (new) action classes.
@mattreaganmozilla @OrlaM I am going to open a separate PR for the redux cleanup, so that it doesn't get blocked by these proposed enhancements. And will rebase this PR once that gets merged in. |
Sorry about the delay getting back to this, it took me some time to think it through. |
This pull request has conflicts when rebasing. Could you fix it @cyndichin? 🙏 |
📜 Tickets
Jira ticket
Github issue
💡 Description
Update redux changes to microsurvey
📝 Checklist
You have to check all boxes before merging
@Mergifyio backport release/v120
)