You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structNewGameScreen:View{@ObservedObjectvarnewGameViewModel:NewGameViewModel=NewGameViewModel()varbody:someView{ScrollView{VStack(spacing:0){CustomTextField(
value: newGameViewModel.state(\.userName),
label:getKmmString(stringResource: \.your_name),
onTextChange:{ text in
newGameViewModel.updateUserName(userName: text)})Spacer().frame(height:32)CustomButton(
text:getKmmString(stringResource: \.start_game),
onClick:{
newGameViewModel.startNewGameButtonTapped()})}.padding(16)}.navigationBarBackButtonHidden(true).onReceive(createPublisher(newGameViewModel.actions)){ action inhandleNewGameAction(action: action)}}privatefunc handleNewGameAction(action:NewGameActions){
switch action {caseletaction as NewGameActionsCreateNewGameAction:do{letnewGameMap=getMapFromFunction(name: action.userName)// Create map herevardocumentReference:DocumentReference?=nil
documentReference =Firestore.firestore().collection(Game.companion.COLLECTION_GAMES).addDocument(data: newGameMap){ error in
if let error {
newGameViewModel.doNewGameCreationFailed()}else if let documentId = documentReference?.documentID, !documentId.isEmpty {
newGameViewModel.doNewGameCreated(newGameID: documentId)}else{
newGameViewModel.doNewGameCreationFailed()}}}caseletaction as NewGameActionsGoToMainScreenAction:do{closeScreen()PalermoHelper().goToMainGameScreen(gameID: action.gameID, name: action.userName)}default:return}}}
When I tap the button, startNewGameButtonTapped() function of viewModel is called and then the action CreateNewGameAction should be handled by iOS.
Sometimes it works and sometimes not. Maybe it is a lifecycle issue, but I am not sure and I do not know how to solve it. Do you have any ideas?
The text was updated successfully, but these errors were encountered:
kostapostolakis
changed the title
iOS Action Handling not working
iOS action handling not working sometimes (maybe lifecycle issue)
Mar 11, 2024
kostapostolakis
changed the title
iOS action handling not working sometimes (maybe lifecycle issue)
iOS action handling not working more times (maybe lifecycle issue)
Mar 11, 2024
I have the NewGameViewModel in commonMain Shared code of KMM.
I have also the NewGameScreen in iOS:
When I tap the button, startNewGameButtonTapped() function of viewModel is called and then the action CreateNewGameAction should be handled by iOS.
Sometimes it works and sometimes not. Maybe it is a lifecycle issue, but I am not sure and I do not know how to solve it. Do you have any ideas?
The text was updated successfully, but these errors were encountered: