-
Notifications
You must be signed in to change notification settings - Fork 520
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
Question: Should I do it the Redux style or not? #344
Comments
Here's my 2 cents:
|
Hi , thanks for your quick response. Actually the presentMoreOptionsActionSheet() create a UIAlertViewController inside the same class and simply present and because it’s located in the same class it has access to the moreOptions enum array. Consider these facts what do you think I should do? Thanks. |
I want to add my 2 cents. I have a big debate internally between a redux aware UI State and pure UIKit UI management. At the moment I'm doing a bit of both, for shared UI and shared modal I do all of it though redux, like this: struct UIState: StateType, Equatable {
enum SelectedTab: Int {
case feed, badges, explore, me, more
}
enum PresentedModal: Int {
case none, login, compose, scan, stats, arkit, booklistEditor, safari, badgeWin, other
}
var selectedTab = SelectedTab.feed
var presentedModal = PresentedModal.none
var presentedModalRelativeTo: UIViewController?
var modalHistory: [PresentedModal] = []
var shouldCloseModal = false
var urlToOpen: URL?
var orientation: UIDeviceOrientation = UIDevice.current.orientation
} UI actions look like that class UIActions: BaseActions {
struct SetSelectedTab: Action {
let selectedTab: UIState.SelectedTab
}
struct PresentModal: Action {
let modal: UIState.PresentedModal
let relativeTo: UIViewController?
}
} And I have a main controller which listen to the UI State and present modal accordingly. Of course, I can't do that for everything, but it helped quite a lot with modal stacking management and routing. |
Hi @Dimillian thanks for your response. Thanks. |
It's a substate of my AppState: struct AppState: StateType, Equatable {
var usersState: UsersState
var booksState: BooksState
...
var uiState: UIState
...
} Then I can connect on it if I want to be specific store.subscribe(self) {
$0.select { $0 }.skipRepeats({ (oldState, newState) -> Bool in
oldState.uiState == newState.uiState
})
} |
Hi @Dimillian I know that a lot of time pass since I your last response on this thread but I have only one questions about the Main View Controller that you mentioned above who's responsible to present the modals. The main view controller is the view controller which contains all the tabs of your app? If not where exactly you are initiate it? Thanks. |
Hi,
I am working on a very big swift project and use ReSwift heavily in it. I always ask myself questions regarding: should I do it the redux style or not and I will explain:
In one of my screens I have a more options button which located on my navigation bar. When I press it the app present an action sheet (UIAlertController) to the user. The list of options which are available inside this action sheet are being calculated inside the reducer and my state contains an array of the list of more options (I use enum). I decided to it this way because this list can be changed according to the item status. So my state look like this:
And when the user click on the more options button I build the UIAlertController dynamically from this list. Everything works as expected without any issues.
Now my indecision is what to do with presenting this action sheet. I have 2 options:
and in order to avoid presenting the action sheet multiple times inside the presentMoreOptionsActionSheet function I dispatch the same action but this time with the value of false so it will not be displayed again
store.dispatch(ItemDetailsActions.SetDisplayMoreOptionsActionSheet(display: false))
I would like to hear your thoughts about it? What do you think should I go with the redux style or not and this question is true for all other scenarios that I may face during the app development.
Thanks in advance.
The text was updated successfully, but these errors were encountered: